Skip to content

Instantly share code, notes, and snippets.

@alobato
Created May 11, 2010 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alobato/397975 to your computer and use it in GitHub Desktop.
Save alobato/397975 to your computer and use it in GitHub Desktop.
Time stamp file names for backups or archives
# 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