Results 1 to 6 of 6
-
12-18-2011, 05:53 PM #1Aspiring Evangelist
- Join Date
- Feb 2010
- Posts
- 393
need backup script for mysql and files
Hi all
I need a backup script that i can run that will backup my files as well as the mysql databases.
Also if possible once the backup is complete if it could then be moved onto my backup server by ftp.
any help would be great.
Steve
-
12-18-2011, 08:15 PM #2Web Hosting Master
- Join Date
- Jun 2003
- Location
- California
- Posts
- 2,786
I dump my MySQL databases into a folder in my /home folder, then use rsync to copy all of the files in /home to a separate server. You might be able to adapt this technique to your situation.
Here is what I do to first optimize and then dump the MySQL databases each night:
PHP Code:#!/bin/bash
# backup each mysql db into a different file, rather than one big file
# as with --all-databases - will make restores easier
OUTPUTDIR="/home/home-sql"
MYSQLDUMP="/usr/bin/mysqldump"
MYSQL="/usr/bin/mysql"
# clean up any old backups - save space
rm "$OUTPUTDIR/*bak" > /dev/null 2>&1
# get a list of databases
databases=`$MYSQL -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
# dump each database in turn
for db in $databases; do
echo $db
$MYSQLDUMP --force --opt $db > "$OUTPUTDIR/$db.bak"
done
.cpan
.cpcpan
.cpanold
.cpanm
cpeasyapache
cpins
cprestore
installd-cleanbackups
installd-watchmysql
MySQL-install
quarantine
virtfs
(Those folders are in my /home folder on my cPanel VPS; you may not have all of them).
-
12-21-2011, 04:54 PM #3Russ
- Join Date
- Mar 2002
- Location
- Philadelphia, PA
- Posts
- 2,517
See: https://github.com/vigeek/MySQL-Database-Backup
Has error handling, exporting, single, full backups, compression, archiving etc.
-
12-22-2011, 01:32 AM #4Junior Guru Wannabe
- Join Date
- Dec 2011
- Location
- United Kingdom
- Posts
- 73
Are you running cPanel/WHM? if so you can take advantage of the built in backup options there
-
12-22-2011, 03:44 AM #5Disabled
- Join Date
- Oct 2011
- Location
- Vilnius
- Posts
- 152
If it's only MyISAM databases it is simpler and less resource consuming to just rsync binary files to destination directory.
-
12-22-2011, 11:15 AM #6Junior Guru Wannabe
- Join Date
- May 2011
- Posts
- 32
I ended up creating my own script:
http://paste.ubuntu.com/778727/
GPL 3.0 License
This script will backup the entire database and will back up my home directory, public directory, and mail. My mail directory is huge which is why I do this seperately.
I keep current configurations of my server apps in my home directory, using mercurial to keep track of changes.
As an aside, server admin scripts should be shell scripts. It's usually faster and much more secure.
Similar Threads
-
Bash Script For SQL and Files Auto Backup
By Kbakos in forum Software & Scripts OffersReplies: 2Last Post: 01-19-2011, 09:49 AM -
Backup All MYSQL Databases To Seperate FIles
By truevision in forum VPS HostingReplies: 13Last Post: 08-17-2009, 01:27 AM -
How to easiest do backup and transfer of mysql files ?
By Klentelaris in forum Hosting Security and TechnologyReplies: 5Last Post: 06-30-2008, 08:29 AM -
Script to ftp and backup certain files on sites?
By GeorgeC in forum Hosting Security and TechnologyReplies: 1Last Post: 03-13-2005, 06:45 AM -
Setting up backup script, but tar is limited to 2 GB files?
By pmak0 in forum Hosting Security and TechnologyReplies: 2Last Post: 06-04-2001, 01:52 AM