Changes

From Amahi Wiki
Jump to: navigation, search
724 bytes added ,  15:54, 18 June 2020
{{MessageBox|backgroundcolor = #faa|image =Warning.png|heading =WARNING|message = This is recommended only for advanced users, proceed with caution.}}It's good practice to periodically backup up your database. This functionality is coming to Amahi soon, but until then there is a simple way to automatize automate it. This can be done using [http://members.multimaniasourceforge.co.uknet/wipe_outprojects/automysqlbackup/ AutoMySQLBackup]script.__NOTOC__
== Features ==
* Backup mutiple multiple MySQL databases with one script. (Now able to backup ALL databases on a server easily. no longer need to specify each database seperatelyseparately)* Backup all databases to a single backup file or to a seperate separate directory and file for each database.
* Automatically compress the backup files to save disk space using either gzip or bzip2 compression.
* Can backup remote MySQL servers to a central server.
* Can e-mail the backup log to any specified e-mail address instead of "root". (Great for hosted websites and databases).
* Can email the compressed database backup files to the specified email address.
* Can specify maximun maximum size backup to email.
* Can be set to run PRE and POST backup commands.
* Choose which day of the week to run weekly backups.
== What it does ==
* Every day it will run mysqldump and gzip will dump your specified databases to the ''/var/hda/files/dbdbbackup/daily'' directory, it will rotate daily backups weekly so you should never have more than 7 backups in there.* Every Saturday it will again backup the databases you have chosen but they will be placed into ''/var/hda/files/dbbackup/weekly'', these will be rotated every 5 weeks so there should never be more than 5 backups in there.* Every 1st of the month it will create a backup of all databases and place them into ''/var/hda/files/dbbackup/monthly''. These will never be rotated so it will be up to you to do your own house keeping. I would suggest taking a copy of this offline every month or two so that if you have a hard drive failure you will be able to restore your database.
Every Saturday == How to Install ==<br /><b><u><big>Ubuntu</big></u></b>* install via apt-get sudo apt-get install automysqlbackup* edit the config file located at <code>/etc/default/automysqlbackup</code> sudo nano /etc/default/automysqlbackup* At the bare minimun, in the config file, edit the BACKUPDIR variable* run automysqlbackup to see if it will again backup works (you should get backups added to your backupdir directory: sudo automysqlbackup* Edit cron: sudo crontab -e* add the following for running cron everyday at midnight 0 0 * * * /usr/sbin/automysqlbackup<br /><b><u><big>Fedora</big></u></b>* Create a share called '''dbbackup'''.* Download the databases you have chosen but they will be placed into script to ''/tmp''directory.<pre style="white-space: pre-wrap; word-break: keep-all;">cd /vartmpwget http://downloads.sourceforge.net/project/automysqlbackup/hdaAutoMySQLBackup/filesAutoMySQLBackup%20VER%202.5/dbautomysqlbackup-2.5.1-01.sh</weeklypre>* Some changes will need to be made for this to work on your HDA. As '''root''' user, these will be rotated every update lines indicated in ''automysqlbackup-2.5 weeks so there should never be more than 5 backups in there.1-01.sh'' to read as follows:<pre>Line 39: USERNAME=rootLine 42: PASSWORD=hdaLine 51: BACKUPDIR="/var/hda/files/dbbackup"Line 65: MAILADDR="root"Line 76: DBEXCLUDE="information_schema performance_schema mysql"Line 79: CREATE_DATABASE=yesLine 94: LATEST=yes</pre><br />
Every 1st of * Rename and copy the month it will create a backup of all databases and place them into ''automysqlbackup-2.5.1-01.sh'' from ''/tmp'' to ''/varusr/hdabin'' and set the permissions:<pre>cd /filesusr/dbbincp /monthlytmp/automysqlbackup-2.5.1-01.sh automysqlbackupchmod 755 automysqlbackup</pre>* Set ''automysqlbackup'. These will never be rotated so it will be up to you to do your own house keeping. I would suggest taking ' as a copy of this offline every month or two so that if you have a hard drive failure you will be able to restore your databasedaily cron job (Optional):<pre>cd /etc/cron.dailyln -s /usr/bin/automysqlbackup</pre>
== How to Install Tips ==* Create a share called '''Database''' with the path To change day of ''/var/hda/files/db''.* Download the script [http://downloads.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%202.5/automysqlbackup-2.5.week (1-01.sh AutoMySQLBackup] file =Monday thru 7=Sunday; defaults to 6=Saturday) for backup, update the number on the following line in ''/tmpautomysqlbackup'' directory. cd /tmp wget http://downloads.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%202.5/automysqlbackup-2.5.1-01.sh* Some changes will need to be made for this to work on your HDA. Use your favorite text editor and update as follows:''USERNAME=debian'' on line 39 to: USERNAME=root''PASSWORD='' on line 42 touser: PASSWORDLine 85: DOWEEKLY=hda6''BACKUPDIR="/srv/backup/db" on line 51 to* To run anytime, as root do the following: BACKUPDIR="/var/hda/files/db"automysqlbackup''MAILADDR="maintenance@example* This script is well documented.com"'' on line 65 Options can be easily customized to:meet your specific HDA requirements. MAILADDR="root"The guidance can be found in the ''DBEXCLUDE=""automysqlbackup'' on , starting at line 76 to: DBEXCLUDE="information_schema"110.''CREATE_DATABASE=no'' on line 79 to: CREATE_DATABASE=yes''LATEST=no'' on line 94 toNOTE: LATEST=yes* Copy the file from ''/tmp'' to ''/usr/local/bin'' and set the permissions: cd /usr/local/bin cp /tmp/automysqlbackup-2.5.1-01.sh . chmod 755 automysqlbackup-2.5.1-01.sh* Set as a daily cron job: cd /etc/cron.daily ln -s /usr/local/bin/automysqlbackup-2.5.1-01.sh* When it's run the first time, it will create the directory structure automatically. It will look like this: daily latest monthly weekly* Each time if it is executed, the script will backup all your databases and tables. Each database will be exported in to ''.sql'' file, zipped, and stpred in its own folder for the respective period, i.e. latest, daily, etc. The sql will include the database/table create syntax as welldoes not already exist.
12,424

edits