Portal Home > Knowledgebase > Articles Database > zipped db backup


zipped db backup




Posted by zodehala, 04-09-2007, 06:41 AM
i can back up db using following command and how can i use tar for backup ?

Posted by Nnyan, 04-09-2007, 02:03 PM
I use " tar -czvf $mydate-sqlback.tar.gz backup.sql " in my script that takes a backup of the mysql db's with a timestamp date (after doing a mysqldump flushing logs) and FTP's it to an offsite server.

Posted by zodehala, 04-10-2007, 04:42 AM
and can i use this like above command

Posted by Nnyan, 04-11-2007, 06:50 PM
Sure just like you use the pipe command above " | " to join the two different commands or you can use separate lines. mysql -u root -p123 db | bzip2 -c > /db.sql is the same as mysql -u root -p123 db bzip2 -c /db.sql now I could be wrong (its been awhile since I researched this can came up with the "best solution") but you more then likely want to do a mysqldump of your db then zip that up. Here is the simple version of a script that I use to do full backups then FTP them to another server (which you dont' have to do). Your account also has to have a relatively updated version of LFTP on it since the older ones are problematic. I also have a few things being checked here that you don't have to but I found that it eliminated most of the script errors that happened on occasion. #! /bin/bash mydate=$(date +%m%d%Y%I%M%p) PATH=$PATH:/usr/local/bin export PATH /usr/bin/mysqldump --flush-logs --opt -u USERNAME -pPASSWORD DBNAME > /dir1/dir2/backup.sql cd /dir1/dir2/ if [ -e backup.sql ] then tar -czvf $mydate-sqlback.tar.gz backup.sql fi then lftp <



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
question aboud mod_qos (Views: 582)