module:automysqlbackup

Available NS6 and NS7

[http://sourceforge.net/projects/automysqlbackup/ AutoMySQLBackup] associates with DB configuration will create Daily, Weekly and Monthly backups of your MySQL databases. There is no panel in the server-manager but the configuration is quite simple with few commands listed above, handle by “config setprop automysqlbackup”. I'm fairly sure that you do not have to modify a lot of options except the email account where logs and files are sent. With this contribs you save your mysql databases in a simple way.

Other Features include:

  • Email notification of backups
  • Databases split and sent by mails
  • Backup Compression and Encryption
  • Configurable backup rotation (no db command yet, you have to do it manualy)
  • Incremental database backups (no db command yet, you have to do it manualy)

only ns7, automysqlbackup backup the database of my other modules nethserver-rh-mariadb{101,102,103}

Stephane de Labrusse at stephdl@de-labrusse.fr

Is this Module helpful to you ? Please consider donating

First you need to install my repository, see how to do it

then you can install my module (not yet available)

yum install nethserver-automysqlbackup --enablerepo=stephdl

There is no panel for manage this contrib, you have to play with db configuration command but normally the options by default could be sufficient.

How to launch the backup

You can launch manually the database backup by a command line with automysqlbackup in a root terminal.

automysqlbackup

otherwise every night, an adjustable cron job start to save your databases.

  • Only NS7

If nethserver-rh-mariadb101, nethserver-rh-mariadb102, ethserver-rh-mariadb102 are installed, then you can dump the database either by the cronjob or manually

/sbin/e-smith/runmysqlbackup-rh-mariadb101
/sbin/e-smith/runmysqlbackup-rh-mariadb102
/sbin/e-smith/runmysqlbackup-rh-mariadb103

If you want to see the db configuration of automysqlbackup.

config show automysqlbackup

You can adjust the time when start the cronJob

* Each 30 Minutes

  config setprop automysqlbackup Hour '*' Minute '*/30'
  signal-event nethserver-automysqlbackup-update

* Each Hour

  config setprop automysqlbackup Hour '*/1' Minute 1
  signal-event nethserver-automysqlbackup-update

* At 3 Hour Am

  config setprop automysqlbackup Hour 3 Minute 1
  signal-event nethserver-automysqlbackup-update

It is the folder where you save you database backup (default is /root/backup/db for NS6 and /var/lib/nethserver/automysqlbackup for NS7). This is the architecture of your backup folder.

keep in mind that the /root and /var/lib/nethserver/automysqlbackup are saved with the backup of your server-manager

  • For NS6
#ls /root/backup/db/
daily  fullschema  latest  monthly  status  tmp  weekly
  • For NS7
# ls /var/lib/nethserver/automysqlbackup/
daily  fullschema  latest  monthly  status  tmp  weekly

If you want to save in another place, you have to do the command below.

config setprop automysqlbackup Backupdir /path/to/other/folder

you have to create manually your new backup directory

mkdir -p /path/to/other/folder

the backup path (not modifiable for the mariadb module) of module nethserver-rh-mariadb{101,102,103} are

/var/lib/nethserver/automysqlbackup-rh-mariadb101
/var/lib/nethserver/automysqlbackup-rh-mariadb102
/var/lib/nethserver/automysqlbackup-rh-mariadb103

the possibility is given to you to save a local directory by automysqlbackup. I suppose that you can not use it for large folder but for a web site with its database it could be useful. not activated by default

config setprop automysqlbackup Backup_local_files /path/to/folder

If you wish to encrypt your backups using openssl (no is default)

config setprop automysqlbackup Encrypt yes

you need to set a password (default is 01234567899876543210)

config setprop automysqlbackup Dbencrypt_password your-password

This option may be useful when you want to save your databases outside of your server by sending them by mails. keep in mind to change the default password

To decrypt run :

openssl enc -aes-256-cbc -d -in encrypted_file_name(ex: *.enc.gz) -out outputfilename.gz -pass pass:your-password

example :

openssl enc -aes-256-cbc -d -in daily_horde_2013-04-26_01h41m_Friday.sql.gz.enc -out daily_horde_2013-04-26_01h41m_Friday.sql.gz \
-pass pass:01234567899876543210

You need to install the rpm nethserver-mail-server and set a password to the 'admin' user

you can choose your type of mail send to the admin (log by default)

config setprop automysqlbackup Mailcontent **<option>**

option :

  • log : send only log file (default)
  • files : send log file and sql files as attachments
  • stdout : will simply output the log to the screen if run manually.
  • quiet : Only send logs if an error occurs to the MAILADDR.

Use the “files” option with the Mailcontent db to save your mysql databases in a mailbox outside of your server, moreover they are saved too in a local folder of your server (by default/root/backup/db)

You need to install the rpm nethserver-mail-server and set a password to the 'admin' user

you can choose the mail account where you sent your mails (default is the mailbox admin of your server).

config setprop automysqlbackup Mailto foo@foo.com

you can determine the size of mails sent (default is 8000 KB).

config setprop automysqlbackup Sizemail 8000

keep in mind that a lot of smtp server reject mail bigger than 10 000 KB or 10MB

There are many options you can modify in automysqlbackup, so for a personal need you can adjust by hand the files below. make a copy before.

cp /etc/automysqlbackup/myserver.conf /etc/automysqlbackup/myserver.conf-old
nano /etc/automysqlbackup/myserver.conf

restoring a .sql file

In a root terminal

cd /root/backup/db/ 

or

cd /var/lib/nethserver/automysqlbackup/

and choose your backup

gunzip file-name.sql.gz

Next you will need to use the mysql client to restore the DB from the sql file.

mysql database < /path/file.sql

NOTE: Make sure you use < and not > in the above command because you are piping the file.sql to mysql and not the other way around

If you want to play with another user or a remote mysql server you can use this command line

mysql --user=username --pass=password --host=dbserver database < /path/file.sql

restoring databases sent by mail attachment

The attachments have been split into multiple files, use this command line to combine them :

cat mail_attachment_2011-08-13_13h15m_* > mail_attachment_2011-08-13_13h15m.tar.bz2

and do this to extract the content

bunzip2 <mail_attachment_2011-08-13_13h15m.tar.bz2 | pax -rv

Warning: Skipping the data of table mysql.event. Specify the –events option explicitly.

SOLVED in 8146 see http://www.linuxbrigade.com/warning-skipping-data-table-mysql-event/#more-135 see that discussion http://bugs.mysql.com/bug.php?id=68376

some solutions : if we want to backup databases

mysqldump -uroot –events mysql > /tmp/mysql.sql

or if we don't want to backup them

mysqldump -uroot –events –ignore-table=mysql.event mysql > /tmp/mysql.sql

Please raise Issues on github