Automatic database Backup

General discussion of OpenCATS

Moderators: RussH, cptr13

Forum rules
Just remember to play nicely once you walk through the door. You can disagree with us, or any other commenters in this forum, but keep comments directed to the topic at hand.

Re: Automatic database Backup

Postby Ilovecats » 15 Mar 2017, 18:00

Thanks and I will try this tonight.

I've always just backed up the OpenCATS directory manually. What is Backingup your MySQL/MariaDB database doing ?
Ilovecats
 
Posts: 28
Joined: 31 Jan 2017, 18:00

Re: Automatic database Backup

Postby cptr13 » 16 Mar 2017, 09:44

The database is all of the actual information.

The directories are the program and resumes.

You need both for a successful restore.

The gui (full) backup, backs up both.
User avatar
cptr13
 
Posts: 405
Joined: 23 Apr 2008, 01:53
Location: Mobile, AL

Re: Automatic database Backup

Postby cptr13 » 16 Mar 2017, 10:15

Ok. I THINK...this will encompass a fully automated backup in Windows. I will write this up and simplify this in the documentation at some point. For now, these are the instructions to do it.
1) Backup the OpenCATS MySQL database
https://www.tectut.com/2016/04/automati ... n-windows/

2) Backup the OpenCATS Directories:
https://www.winhelp.us/configure-automa ... ows-7.html

I would recommend, setting the database backup to run first. Then running the step 2 backup to include the OpenCATS directories AND the mysql backup file from step 1.

This should give you a full backup, automatically run and placed on an external hard drive.

WARNING: You must, must must must to a test restore to make sure everything is working. I would recommend doing an occasional test restore on an ongoing basis. You don't want to be caught with a bad backup when you need it....
User avatar
cptr13
 
Posts: 405
Joined: 23 Apr 2008, 01:53
Location: Mobile, AL

Re: Automatic database Backup

Postby kevinharper » 11 Oct 2017, 21:58

I need a solution for a non-technical client that automates the backup process on Unix (Dreamhost). Since OpenCATS already has a full backup feature, it seems like it would be easy to create a script that:

1) Creates a full backup of OpenCATS on a schedule I can determine. Preferably hourly for 24 hours, then daily for a month.
2) Timestamps the zip file for future download.
3) Emails a copy of the zip file if desired, or uploads to Dropbox, FTP, etc.

Has someone created something like this already, or would someone be interested in doing so? Please PM me.

My idea would be to write a bash script then put it on a cron job. I'm not a trained coder, but could probably hack my way through some of this, but if someone has already done it, or can offer pointers, your assistance will be appreciated. :-)
--Kevin

Kevin Harper
www.resultsinternet.com
208-249-8893
User avatar
kevinharper
 
Posts: 18
Joined: 15 Sep 2017, 22:17
Location: Idaho

Re: Automatic database Backup

Postby cptr13 » 12 Oct 2017, 19:14

I'm not aware of anything like this. If you put something together please share it. There's a lot of folks using shared-hosting. I'm sure it could be tweaked and used.
User avatar
cptr13
 
Posts: 405
Joined: 23 Apr 2008, 01:53
Location: Mobile, AL

Re: Automatic database Backup

Postby kevinharper » 14 Oct 2017, 02:39

Here is what I have so far. I put this on a cron that runs every other hour during business hours M-F. The script generates a Gzip MySQL backup and a Zip full file backup. It then checks and removes any backups older than 7 days.

I added this to GitHub in case others want to improve it.

https://github.com/kmharper/opencats-autobackup

Code: Select all
#!/bin/sh
#
# OpenCATS Autobackup v0.0
# By Kevin Harper
# ResultsInternet.com
# kevinmharper@gmail.com
#
# This script creates a MySQL backup and Gzips it, creates a full file backup
# and zips it, then deletes backups older than 7 days. Place it on a cron and
# schedule to your preferences.
#
# Set MySQL credentials
#
THEHOST="mysqlhost.com"
THEDB="mysql_db"
THEDBUSER="mysql_user"
THEDBPW="mysql_pass"
THEDATE=`date +%d%m%y%H%M`
#
# Set other variables
#
THESITE="livesite.com"
THEBACKUPPATH="/path/to/backups/"
THESITEPATH="/path/to/livesite.com"
#
# Make MySQL backup
#
mysqldump -h $THEHOST -u $THEDBUSER -p${THEDBPW} $THEDB | gzip > ${THEBACKUPPATH}${THESITE}_mysql_${THEDATE}.gz
#
# Make file backup
#
zip -r ${THEBACKUPPATH}${THESITE}_files_${THEDATE}.zip ${THESITEPATH}
#
# Remove backups older than 7 days
#
find ${THEBACKUPPATH}${THESITE}* -mtime +7 -exec rm {} \;
--Kevin

Kevin Harper
www.resultsinternet.com
208-249-8893
User avatar
kevinharper
 
Posts: 18
Joined: 15 Sep 2017, 22:17
Location: Idaho

Re: Automatic database Backup

Postby kevinharper » 20 Oct 2017, 23:53

@cptr13 True, but this install is on a shared server environment. Dreamhost. So far, the script I posted for automating this is working beautifully. I'd like it to be a little more elegant for non-technical users to download and restore from a backup, but I at least have peace of mind. :)
--Kevin

Kevin Harper
www.resultsinternet.com
208-249-8893
User avatar
kevinharper
 
Posts: 18
Joined: 15 Sep 2017, 22:17
Location: Idaho

Previous

Return to OpenCATS Talk

Who is online

Users browsing this forum: No registered users and 1 guest