Suse & OpenSuse : Tips, Tricks, Tutorials, How Tos and Troubleshooting

Automatically dating your tar backups

Normally, we use the tar command coupled with some compression program such as gzip to create a backup of our directories. I.e.

# tar -cf /var/log/backup/tux.tar /home/tux

to backup the home directory of the user tux into the directory  /var/log/backup.

However, if we are going to do this on a regular basis, we will be overwriting the file tux.tar.  This would mean that we will only have one snapshot of the user tux home directory.

To keep copies of backups from different times, you will need to use different filenames, preferably with a date indicator.  You can easily do this by,

# tar –cf /var/log/backup/tux-`date +%F`.tar /home/tux

Of course, if you backup a few times within the day, then you may want to use a different option from the +%F format option.

RSS feed | Trackback URI

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.