Skip to content

Instantly share code, notes, and snippets.

@vekexasia
Created April 22, 2012 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vekexasia/0c0b86919ea5b4c16557 to your computer and use it in GitHub Desktop.
Save vekexasia/0c0b86919ea5b4c16557 to your computer and use it in GitHub Desktop.
Backup :)
[client]
host = localhost
user = backupuser
password = your-password-here
socket = /var/run/mysqld/mysqld.sock
#!/bin/bash
mkdir -p ~/mysqlbackups/
for i in $(mysql -Bse "show databases"); do
mysqldump $i > ~/mysqlbackups/$i.sql
done
CREATE USER 'backupuser'@'localhost' IDENTIFIED BY 'your-password-here';
GRANT SELECT ,
LOCK TABLES ,
SHOW VIEW ON * . * TO 'backupuser'@'localhost' IDENTIFIED BY 'your-password-here' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
config_version 1.2
snapshot_root /your/backup/folder/
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
retain daily 7
retain weekly 7
retain monthly 3
#client1 backups
backup backupper@client1:/home/backupper/mysqlbackups client1/
backup backupper@client1:/etc client1/ +rsync_long_args=--rsync-path='sudo rsync'
backup backupper@client1:/var/www client1/ +rsync_long_args=--exclude '/stats/*' --exclude '/log/*' --exclude '/phptmp/*' --exclude '/cache/*' --rsync-path='sudo rsync'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment