Results 1 to 10 of 10
Threaded View
-
8th Dec 2011, 08:23 AM #2MemberWebsite's:
motionlite.netFirst, here is the script, call it backup.pl and put it in a folder outside the root of your sites.
You set it to run daily using cron, but can set an offset. I have mine set at 3 so it runs at 3am.
PHP Code:backup.pl
================
#!/usr/bin/perl
#### CONFIG ####
$backupHour = 3; # TIME TO RUN THE backup
$backupPath = "/backup"; #This is the folder where your backup file set file is stored
$backupFileName = "backup.tar.gz"; #The name you want to give to your tar file
$backupFileList = "file_list.txt"; #The list that you use to determine what parts to back up
$HostHasMySQL = 0; # 1 = YES, 0 = NO
$MySQLRootPassword = '';
$MySQLbackupFileList = "mysql_list.txt"; #The list that you use to determine which databases to backup.
################
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($hour == $backupHour) {
if ($HostHasMySQL == 1) {
&DumpDatabases;
}
&backupFiles;
}
#### SUBS ####
sub backupFiles
{
# remove old backup file
$systemresult = system("rm $backupPath\/$backupFileName");
# create .tar.gz file
$systemresult = system("tar czvf $backupPath\/$backupFileName -T $backupPath\/$backupFileList \&>\/dev\/null");
}
sub DumpDatabases
{
my $name;
if (open(DBLIST, "$backupPath\/$MySQLbackupFileList")) {
while (<DBLIST>) {
if (/^\s*\#/ ?? /^\s*$/) {
# Ignore Comments and Blank Lines
} elsif ( /^\s*([\w]+)\s*/ ) {
$name = $1;
$systemresult = system("mysqldump --opt --user=root --password=$MySQLRootPassword $name > $backupPath$
}
}
close (DBLIST);
}
}
eg:
/www/home
/www/public
/etc/passwd
The bottom one, shows that you can also back individual files up. If you put a folder in the list, it will backup the contents of that folder, and all subfolders.
For the mysql_list.txt - just enter the dabase names onto separate lines.
eg:
site1dbase
site2dbase
mydbase
Set it up to run either on cron, or run it from the cammand line.
A tar.gz file will be created - if you want to get this off, then you will need to download it off your server - but beware, if all your sites and databases are in it, it could be a large file!
Hope this helps,
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
SHOUTcastUK Backup Service Give away
By UKInternetGroup in forum Contests & GiveawaysReplies: 14Last Post: 9th May 2012, 06:17 PM -
CrownCloud - Backup solution - Backup your sites today ! For $5/Month
By speedbus in forum Other Hosting OffersReplies: 0Last Post: 17th Apr 2012, 06:55 AM -
should use the service to backup files?(MF or RS)
By danhtin2108 in forum File Host DiscussionReplies: 14Last Post: 11th Feb 2012, 10:31 AM -
which Service you use for Backup purpose of important data
By pioneer_fawad in forum Webmaster DiscussionReplies: 6Last Post: 9th Oct 2011, 02:10 PM -
Need a backup hosting service
By Hero of war in forum Hosting DiscussionReplies: 3Last Post: 5th Apr 2011, 04:05 PM
themaCreator - create posts from...
Version 3.52 released. Open older version (or...