Quote:
Originally posted by LasseW
I think there's a slight flaw in your logic here: the first tar command will create a new file. All files in the mysql directory will be new to the dated file, so the u flag isn't selective at all, it's the same as using the c flag. I'm also wondering what the second tar command does
|
I wish to create a daily backup of the mysql datases:
#tar -uf /backups/mysql/mysql.`date +%Y-%m-%d`.tar /var/lib/mysql
The first day it runs it gives me:
mysql.2004-11-08.tar
Then the dated archive is tarred into a master archive named "mysql.appended.tar":
#tar -uf /backups/mysql/mysql.appended.tar /backups/mysql/*.tar
Resulting in "mysql.appended.tar.gz"
The next day the script runs again and creates "mysql.2004-11-09.tar".
Now I have two dated tar files in my backup directory:
mysql.2004-11-08.tar
mysql.2004-11-09.tar
When the second step of the script runs, it takes the existing tar files (*.tar) then and appends them to the master tar file (mysql.appended.tar). Because of the "u" switch, it should ignore the file from the 8th since it already exists in the master archive and add only the tar from the 9th.
The same thing happens on the 10th, creating "mysql.2004-11-10.tar". when the files are appended to the master archive the ones from the 8th and 9th should be ignored and only the one from the 10th should be added. And so on...
What I have instead is a master tar file that doubles in size each time the script runs. For instance, on the second day I found that the script was appending all the tar files to the master archive instead of only the newest one that was not already in the archive. When I extract the existing archive I found two copies of each dated archive file. I want to know why the "u" switch is not working as I thought it should.
[root@xxxxxxx floppy]# tar zxvf mysql.appended.tar.gz
backups/mysql/mysql.2004-11-08.tar
backups/mysql/mysql.2004-11-09.tar
backups/mysql/mysql.2004-11-08.tar
backups/mysql/mysql.2004-11-09.tar
Since my databases are small enough to fit a weeks worth of zipped backups onto a floppy this provides me a small level of security should my hdd fail. In case a floppy goes bad I also want to leave a copy of the dated archives on the hdd as well in case I need to restore the databases. I suppose I can simply move the dated archive file, once added to the master archive, to a different directory so it will not be added again to the master archive the next day but I don't understand why it is duplicating the dated files in the first place.
Quote:
Originally posted by LasseW
note that the target file mysql.appended.tar will match the source pattern *.tar.
|
I thought of that but if it did, why does it not appear in the extracted file list when I extract the master archive? Instead of...
[root@xxxxxxx floppy]# tar zxvf mysql.appended.tar.gz
backups/mysql/mysql.2004-11-08.tar
backups/mysql/mysql.2004-11-09.tar
backups/mysql/mysql.2004-11-08.tar
backups/mysql/mysql.2004-11-09.tar
Why do I not see...
[root@xxxxxxx floppy]# tar zxvf mysql.appended.tar.gz
backups/mysql/mysql.2004-11-08.tar
backups/mysql/mysql.2004-11-09.tar
backups/mysql/mysql.appended.tar
backups/mysql/mysql.2004-11-08.tar
backups/mysql/mysql.2004-11-09.tar
backups/mysql/mysql.appended.tar
Just curious as to why it is doing what it is doing. TIA!
