Wednesday, January 03, 2007
Create tar files with date and time stamp
There are many different tools to deploy files or directories of files from server to server. There's tar, rsync, remote copy ... a bunch of things. Whichever method you use, it's in your best interests to make a backup.
To help you keep track of the backups you make at any time, use "date" along with "tar" to create timestamped files:
tar -cvfX filename_`date +%Y%m%d_%H%M%S`.tar *
Now, if you need to back out the tar file you explode you can just go get your previously dated version.
To help you keep track of the backups you make at any time, use "date" along with "tar" to create timestamped files:
tar -cvfX filename_`date +%Y%m%d_%H%M%S`.tar *
example:
# find .
./somedir
./somedir/a.txt
./b.txt
./c.txt
# tar -cvfX filename_`date +%Y%m%d_%H%M%S`.tar *
a build.sh 0K
a c.txt 0K
a somedir/ 0K
a somedir/a.txt 0K
# ls *.tar
filename_20070103_101105.tar
Now, if you need to back out the tar file you explode you can just go get your previously dated version.