Creating Back-Ups


#1

I’ve never used Dreamhost before, and their control panel is VERY different from my other 2 hosts. I’ve searched through everything in the panel and cannot find a way to create a backup.

Could someone please tell me how to create a backup of my domain via the control panel? I’d really hate to lose everything due to an outtage or some random problem/hacker.


#2

We do keep backups, but we don’t have any sort of way to automatically download a backup of your site.

From the command line you can create a tarball of your site and then download it to your local machine…

something like (untested):

tar cvzf backup.tar.gz /home/[yourusername]


#3

There’s a much easier way of doing a backup than messing around with the command line. Using your favorite FTP client, drag the contents of your web folder into a local folder to backup your static files, and then do a MySQL dump using the MySQLAdmin panel to backup your database.


Simon Jessey
Keystone Websites | si-blog


#4

will:

[/quote]

I’d like to be able to make backups of my sites this way but run it with a cron job. How would I go about setting that up? Creating the script? Is there something simple out there that someone at Dreamhost is using to do this?


#5

Also remember that DH automatically creates a full backup of your websites every six hours. You can find the backup archive as a hidden directory in your user directory, where there are hourly.0, hourly.1, nightly.0, nightly.1, weekly.0, weekly.1 subdirectories. This is simply excellent if you/users/hackers mess up!

Read more:
https://panel.dreamhost.com/kbase/index.cgi?area=2585
There’s also this about database backups:
https://panel.dreamhost.com/kbase/index.cgi?area=2931&keyword=backup

TorbenGB
Try out DreamHost with a free WebIDPrices, options


#6

Try this script (I use this every month to automatically GZ my sites and FTP them to my FTP Server @ Home

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);

###############################################

World Wide Backup Copywright 2001 WORLD WIDE CREATIONS www.worldwidecreations.com

You are free to use this software any way you wish provided you follow the following terms:

That you cannot use the source in any script/software you redistribute or sell in any way.

You can NOT redistribute this software in any way.

For complete licensing terms, please contact us at our website at www.worldwidecreations.com

This software was created on October 4th 2001.

This software is intended to create a backup file called backup.tar.gz on your server

then the software will FTP this software anywhere you wish, providing you have

access to the said FTP server. You can also choose NOT to FTP the backup file

if all you wish is to use this to create a backup file.

You can choose to timestamp the backups.

This software was tested on a Linux platform with a GNU version of Tar

You may need to modify the code slightly if your system will not use gzip.

You can crontab this script, but you should make sure you do not set the cronjob

too frequently as this could use up your bandwidth quickly if you set a cronjob to

execute too often. You should test this script first without a cronjob and make sure everything is working

correctly, before you set this up as a working backup.

A weekly crontab would look something like:

0 0 * * 1 perl /path/to/backup.pl

This would execute the script every Monday.

Dont forget to define your Path to Perl and to CHMOD this 755.

This script is not designed to run as a CGI WEB script.

you can attempt it if you wish, but with a large backup your browser will likely

time out. Use telnet or crontab instead.

Support can be found in our forum at www.worldwidecreations.com

###############################################

##If you want to timestamp the filename, select this as 1, otherwise 0;
$date_yes = 0;

##If you DONT want the script to FTP this somewhere then check this 1, otherwise leave as 0
$just_back_up = 0;

#If you want the backup file deleted on the SOURCE server after FTP quits, check this as 1;
$delete_source = 1;

#Path to the directory you want to be as your base directory to back up.
#All files AND directories off of this path will be archived. NO TRAILING SLASH
$basepath = “”;

#Path to the directory you want to be as your base directory to back up.
#All files AND directories off of this path will be archived. NO TRAILING SLASH
$basepath2 = “”;

#Path to the directory you want to be as your base directory to back up.
#All files AND directories off of this path will be archived. NO TRAILING SLASH
$basepath3 = “”;

##Where you want the backup.tar.gz file to be placed (not where it will be FTP’d). NO TRAILING SLASH!
$tarpath = “”;

##FTP server
$ftpserver = “”;

##FTP username
$ftpusername = “”;

##FTP password
$ftppass = “”;

##CWD directory, in other words, when the script logs into the FTP server, where would you like the backup.tar.gz file to be placed
$cwdd = “”;

##want to be notified of transfer status by email (sendmail required)?
$notify = 0;

#path to sendmail
$sendmail = “/usr/sbin/sendmail”;

##email address:
$to = ‘’;

##Who will the email address be from
$from = ‘’;

##Backup File Prefix
$prefix = ‘’;

##############################NO MORE EDITING REQUIRED ####################################
use Net::FTP;
$hitch = ();
($day, $month, $year) = (localtime)[3,4,5];
$year = $year + 1900; $month++;
if ($date_yes) { $hitch = “$month-$day-$year”; }
print “ARCHIVING FILES\n”;
@the = tar --exclude $prefex$hitch.tar.gz -czf $tarpath/$prefix$hitch.tar.gz $basepath $tarpath/$prefix$hitch.tar.gz $basepath2 $tarpath/$prefix$hitch.tar.gz $basepath3;
@mat = stat("$tarpath/$prefix$hitch.tar.gz");
if ($mat[7] <= 0) { print “Backup didnt happen. The error returned by the system (if any) is @the\n”; &send(“Backup FAILED. Tar did not backup any files. Error message returned from server (if any) is @the”, “Backup FAILED”); exit; }
print “Files Archived to $prefix$hitch.tar.gz\nFile Size Is $mat[7] Bytes\n”;
if ($just_back_up) {
&send(“Backup success. Backup size $mat[7] bytes”, “Backup Success”);
print “Ok, files are backed up, No FTP requested. Shutting down\n”;
exit;
}
print “Connecting into server\n”;
if ($ftp = Net::FTP->new("$ftpserver", Debug => 0)) { print “Logging in to server\n”; } else { print “could not find server! Exiting\n”; &send(“Backup FAILED. Could NOT connect to $ftpserver”, “Backup FAILED”); exit; }
if ($ftp->login("$ftpusername","$ftppass")) { print “Username and Password ACCEPTED\n”; } else { print “could not log into server with Username and Password. Exiting!\n”; &send(“Backup FAILED. Could NOT connect to $ftpserver with the Username And Password provided - Authentication error.”, “Backup FAILED”); exit; }
if ($ftp->cwd("$cwdd")) { print “Changed to the directory without any trouble - UPLOADING\n”; } else { print “Could not change to the appropriate directory, uploading anyway\n”; }
if ($ftp->binary) { print “Changed to Binary Mode No Problem\n”; } else { print “Could not change to binmode $!\n”; exit; }
if ($ftp->put("$tarpath/$prefix$hitch.tar.gz")) { print “Everything appears ok with the upload\n”; } else { print “Can not upload file $!\n EXITING\n”; &send(“Backup FAILED. Could NOT upload to $ftpserver. Error message returned from server is: $1”, “Backup FAILED”); exit; }
$ftp->quit;
if ($delete_source) {
print “You chose to delete the source after FTP, deleting $tarpath/$prefix$hitch.tar.gz…”;
unlink("$tarpath/$prefix$hitch.tar.gz") or print “COULD NOT DELETE! $!”;
print “\nDeleted!\n”;
}
print “File Transferred OK!\nFinished\n”;
if ($notify) {
&send(“Backup success. Transferred $mat[7] bytes to $ftpserver”, “Backup Success”);
}

sub send {
if ($notify) {
open MAIL, “|$sendmail -t” or print “Could not open Sendmail $!\n”;
print MAIL “To: $to\nFrom: $from\nSubject: $[1]\n\n$[0]\n\n.\n”;
close MAIL;
}
}


#7

Hey, So many great solutions! Thanks guys. I need to create the cron because I need to back up a database but I did not know about these “hidden” backups. These could be a real lifesaver for someone.

More from that Kbase page:

Steps for restoring data on your own :

[from the shell] cd into the hidden directory named .snapshot (it will not show up in a directory listing at all, but it’s there)

Choose how far back you would like to go ( hourly.0 is one hour ago, hourly.1 is two hours ago, nightly.0 is one day ago, nightly.1 is two days ago, weekly.0 it one week ago, weekly.1 is two weeks ago )

Copy the restored file to where you want it. You’re done!

cool.


#8

Actually, the wording is misleaing, since backups are made every 8 hours. That means “hourly.0” is within the past 8 hours, and “hourly.1” is between 8 and 16 hours ago.

Backups are made at at 8 am, 4 pm, and midnight Pacific time. The nightly backups are the ones taken at 4 pm. The weekly backups are Sunday at 4 pm. (Or at least that’s how it is on my account.)