1. backupシェル
#!/bin/sh
# Set mask for other user cann't read
umask 077
# backup file
# Retention period
period=31
# directory for backup files
dirpath='/home/pi/backup/mysql'
# backup file naming
filename=`date +%y%m%d`
# excute
mysqldump --opt --all-databases --events --default-character-set=binary -u root --password=xxxxxxxxx | gzip > $dirpath/$filename.sql.gz
# delete old backup files
oldfile=`date --date "$period days ago" +%y%m%d`
rm -f $dirpath/$oldfile.sql.gz
2. sudo crontab -l
0 2 * * * /home/pi/prj/sql/mysql_backup.sh > /tmp/cron-bk.stdout 2 > /tmp/cron-bk.stderr || [ $? -eq 1 ]
3. WIndowsマシンへのバックアップ
0 件のコメント:
コメントを投稿