Skip to content

Instantly share code, notes, and snippets.

@binhp
Created April 4, 2018 04:32
Show Gist options
  • Save binhp/f6c41db44aa243110dc647514c1ed356 to your computer and use it in GitHub Desktop.
Save binhp/f6c41db44aa243110dc647514c1ed356 to your computer and use it in GitHub Desktop.
Backup Daily with logrotate

Daily backup with logrotate

## sudo touch /var/backup/dbname.sql.gz
## test
## sudo logrotate -f /etc/logrotate.d/mysqlbackup
## sudo vi /etc/logrotate.d/mysqlbackup
/var/backup/dbname.sql.gz {
daily
rotate 7
nocompress
create 640 root root
postrotate
mysqldump -u dbuser dbname |gzip > /var/backup/dbname.sql.gz
echo "Backup at `date`" > /var/backup/dbname.log
endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment