MySQL Backup to a share

  • Create a share on a server
  • Install cifs-utils: apt-get install cifs-utils
  • Create a folder under /mnt for mounting:
    mkdir /mnt/backup
  • Inside of /etc/fstab define the mountpoint:
//backupserver/Linux_Backups   /mnt/backup   cifs    credentials=/etc/cifspw    0       0
  • Create /etc/cifspw with credentials für a „mounting-user“

> Ubuntu 12


< Ubuntu 13

  • Try via mount -a if mounting works and verify output of df or simply go to /mnt/backup (cd /mnt/backup)
  • Create a file called inside of /usr/sbin and add this content:
for db in 'mysqlshow -u $user -p$password | sed -n -e "s/^| \([^ ]*\)[ ]*|$/\1/p"'  
do mysqldump --opt -u $user -p$password $db > /mnt/backup/ /mysql/$db.sqldone

After creation do chmod a+x so that the script can be executed

  • To automate the job create a cronjob under /etc/cron.d called mysql_backup (or do it via crontab –e)
00 02 * * *     root    /usr/sbin/ >/dev/null 2>&1

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.