Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am using tar to backup portions of my Linux server to another disk on a WinXP machine via a mounted share. I run the backup as a cron job each night.
The command I'm using now (tar -czvf /mnt/HelixBackups/Helix_backup.tar.gz /var/www /home /var/lib/mysql /etc/my.cnf) works well, backing up the files I want archived, and storing the tar file on the windows machine. It has an obvious drawback, however, in that each time it is run, it destroys the previous night's backup in favor of the current one, due to the filename being specified on the command line.
Is there a way to automatically genterate a unique filename each night, perhaps based on the date? That way I could keep a week or so of backups on the drive...
You bet:
Using the "date" command (note, the ( ` ) is a backtick, next to the 1 key):
"tar -czvf /mnt/HelixBackups/Helix_backup.`date +%d%m%y`.tar.gz ...."
Ian
Last edited by green_dragon37; 12-20-2003 at 12:18 PM.
Thank you for your quick response, green_dragon37!
Now, so that I don't have weeks and weeks of these backup files accumulating on my disk, I'd like to delete those that are over a certain age old. So, if I scheduled another cron job to run after the completion of the backup job, and decided I wanted to keep three days of backup tars but delete anything older than that, would the following command work?
I put this command together by piecing together various pieces of data found with Google. It looks (to my inexperienced eye) like it would do the job, what do you think? On some of the reference sites I saw, the line was terminated with a semi-colon (, is that required here?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.