Results 1 to 4 of 4
Thread: backup script help
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Mar 2006
backup script help
cp -r /home/www/* /backups/%date%
tar -cvzf /backups/%date%.tar.gz /backups/%date%/
You probably want to capture the output of the 'date' command into a variable, and use it repeatedly. The 'date' command reports the time and date including seconds, so its output changes frequently, so its not just a convenience to call it once, but a necessity.
You can change the format of the time and date reported by 'date' with command line flags.Linux user #126863 - see http://linuxcounter.net/
There is so many threads on that subject, I'm sure you can find something interesting in one of them.
Like this one for example :
http://www.linuxforums.org/forum/lin...t-newbies.html"To express yourself in freedom, you must die to everything of yesterday. From the 'old', you derive security; from the 'new', you gain the flow."
Unless there is a reason (like rapidly changing data files), I wouldn't copy everything and then tar it, I would just tar it in place.
For example, today this would create file /backups/www090806.tar.gz which backs up all files in /home/www.
tar -cvzf /backups/www$(date +%m%d%y).tar.gz /home/www