Created
May 11, 2010 22:37
-
-
Save alobato/397975 to your computer and use it in GitHub Desktop.
Time stamp file names for backups or archives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Time stamp file names for backups or archives | |
# http://www.24hourapps.com/2009/02/linux-tips-8-time-stamp-file-names-for.html | |
# When doing simply backups (non-incremental) it is useful to be able to automatically | |
# time stamp or date stamp file names. This makes archives much easier to navigate when | |
# it comes time to retrieve a backup. | |
# The command for doing this is quite simple. To just create a file with a time stamped file name, | |
# use the following command: | |
touch myfile-$(date '+%Y-%m-%d-%T') | |
# The command will produce a file called myfile-2009-02-25-17:32:01 You can also use it to make | |
# backups when combined with tar. The following code will create a date stamped gzipped tar file | |
# of a directory called test. | |
tar czvf test_backup_$(date '+%Y%m%d').tgz test/ | |
# Using the above commands with cron can allow you to quickly create a very simple, yet effective, | |
# backup system for any important folders that you need to archive. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment