Backup

From SWKLS WIKI
Jump to navigation Jump to search

MySQL

Auto MySQL Backup

  • Login to server via SSH and change user to root
1 sudo -i
  • Download the AutoMySQL backup tar file.
1 wget https://swkls.org/tmp/automysqlbackup-v3.0_rc6.tar.gz
  • Create a directory in /opt and extract the downloaded file.
1 mkdir /opt/automysqlbackup
2 mv automysqlbackup-v3.0_rc6.tar.gz /opt/automysqlbackup/
3 cd /opt/automysqlbackup
4 tar -zxvf automysqlbackup-v3.0_rc6.tar.gz
  • After the extraction install the AutoMySQL backup
1 ./install.sh

You can use the default path for the global configuration directory and the directory for the executable. You only need to press the “Enter” key when the paths are required.

  • After the installation, you have to configure AutoMySQL backup. Open the configuration file with your favorite text editor.
 1  
 2 vi /etc/automysqlbackup/automysqlbackup.conf
 3 
 4 Uncomment and set the following configuration directives:
 5 CONFIG_mysql_dump_username='root'
 6 CONFIG_mysql_dump_password='YourPassword'
 7 CONFIG_mysql_dump_host='localhost'
 8 CONFIG_backup_dir='/var/backup/db'
 9 CONFIG_do_monthly="01"
10 CONFIG_do_weekly="5"
11 CONFIG_rotation_daily=6
12 CONFIG_rotation_weekly=35
13 CONFIG_rotation_monthly=150
14 CONFIG_mysql_dump_port=3306
15 CONFIG_mysql_dump_use_separate_dirs='yes'
16 CONFIG_mysql_dump_compression='gzip'
17 CONFIG_db_exclude=( 'information_schema' 'performance_schema' )

You can configure the AutoMySQL backup by changing the values according to your needs.

  • Create a directory for the MySQL backups. In the configuration we have mentioned the directory /backup/db.
1 mkdir /var/backup
2 mkdir /var/backup/db
  • To run the AutoMySQL backup execute the following command.
1 /usr/local/bin/automysqlbackup
  • If you want you can schedule the AutoMySQL backups to run on a specific time by creating a cronjob.
1 crontab -e
2 
3 Add Line:
4 0 2 * * * /usr/local/bin/automysqlbackup /etc/automysqlbackup/automysqlbackup.conf

Here the backup is scheduled at 2 AM.

Synology

Basic NAS Setup

  • create shared folder 'backups', no recycle bin if used for staff backups
  • create user 'backupuser'
  • create 'staff' group
  • give 'staff' group rw to 'backups' folder, add 'backupuser' to 'staff' group
  • set notifications
  • swkls+synologynas@mycheckcentral.cc
  • mail.checkcentral.cc
  • 587
  • install 'Cloud Sync' and 'Storage Analyzer' packages
  • enable power-on after power failure & WOL
  • enable basic SSH
  • enable DDNS (synology). Use verso_code+nas i.e. haconas for name
  • enable automatic package updates

Email Alerts

swkls+synologynas@mycheckcentral.cc

mail.checkcentral.cc

587