...
As you can see in the configuration above, we use scripts in order to do MySQL and Redis dumps. The scripts are stored on the backup server. Put them under your /opt/backups/ directory, and modify the HOST variable to suit your needs:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#!/bin/bash HOST="10.60.20.100" MYSQL_DB="kinton" FILE=${MYSQL_DB}.$(date +"%Y%m%d-%H%M%S").sql.gz # dump the database and gzip it ssh root@${HOST} "mysqldump ${MYSQL_DB}" | gzip -9 > ${FILE} |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#!/bin/bash HOST="10.60.20.101" REDIS_DUMP="/var/lib/redis/dump.rdb" FILE=dump.$(date +"%Y%m%d-%H%M%S").rdb.gz # dump the database and gzip it ssh root@${HOST} "redis-cli save" ssh root@${HOST} "cat ${REDIS_DUMP}" | gzip -9 > ${FILE} |
...
Automation is easily attainable using a simple crontab entry. Open /etc/crontab and add the following:
...
Code Block |
---|
#MAILTO="" ##Supresses output
MAILTO=me
###################################################################
#minute (0-59), #
#| hour (0-23), #
#| | day of the month (1-31), #
#| | | month of the year (1-12), #
#| | | | day of the week (0-6 with 0=Sunday)#
#| | | | | commands #
###################################################################
15 02 * * * /usr/bin/rsnapshot -c /etc/rsnapshot/laptop.rsnapshot.conf daily
15 03 * * Sun /usr/bin/rsnapshot -c /etc/rsnapshot/laptop.rsnapshot.conf weekly
30 03 1 * * /usr/bin/rsnapshot -c /etc/rsnapshot/laptop.rsnapshot.conf monthly
|
This setup runs a daily backup at 2:15am, a weekly backup on Sunday at 3:15am, and a monthly backup on the first of the month at 3:30am.