1. 程式人生 > >定時備份程式碼和資料庫指令碼

定時備份程式碼和資料庫指令碼

# backup mysql
backupdir=/opt/backup
time=` date +%Y_%m_%d_%H_%M_%S `
db_host=192.168.1.2
db_user=root
db_pass=root
mysqldump --all-databases -h $db_host -u $db_user -p$db_pass | gzip > $backupdir/$time.sql.gz

# backup code
backupdircode=/opt/backup
time=` date +%Y_%m_%d_%H_%M_%S `
tar czvf $backupdircode/$time.code.gz /var/web/www/html