Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
howto:daily_backup [2016/03/22 00:03] 127.0.0.1 external edit |
howto:daily_backup [2018/12/08 22:28] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | In order to create daily mysql and ldap backup you can put this small script in /etc/cron.daily/: | + | In order to create daily mysql and ldap backup you can put this small script in ''/etc/cron.daily/'': |
- | #!/bin/bash | + | <code bash> |
- | + | #!/bin/bash | |
- | mkdir -p /srv/backup | + | |
- | mysqldump -uroot -p"$(sudo cat /etc/yunohost/mysql)" mysql > /srv/backup/backup-$(date +"%m-%d-%y").mysql | + | mkdir -p /srv/backup |
- | slapcat > /srv/backup/backup-$(date +"%m-%d-%y").ldap | + | mysqldump -uroot -p"$(sudo cat /etc/yunohost/mysql)" mysql > /srv/backup/backup-$(date +"%m-%d-%y").mysql |
- | find /srv/backup -mtime +10 -exec rm {} \; | + | slapcat > /srv/backup/backup-$(date +"%m-%d-%y").ldap |
- | chown root. /srv/backup | + | find /srv/backup -mtime +10 -exec rm {} \; |
- | chmod -R 740 /srv/backup | + | chown root. /srv/backup |
+ | chmod -R 740 /srv/backup | ||
+ | </code> | ||
Make the script executable | Make the script executable | ||
- | chmod +x /etc/cron.daily/backup | + | <code bash> |
+ | chmod +x /etc/cron.daily/backup | ||
+ | </code> | ||
+ | This script save all your databases and your ldap in ''/srv/backup'' for the last 10 days. | ||
- | This script save all your databases and your ldap in /srv/backup for the last 10 days. |