Web Hosting Talk







View Full Version : Best Way to Backup Your Server?


NVB
08-18-2001, 11:13 PM
I would like to backup my server on a daily basis with a cron job. There is under 100 MB worth of data. I want to do spend as little money as possible.

What is the best way to accomplish this task?
Is there a simple script or command?
Would it be better to use software?
If so, what software would you recommend?

In addition to the tar backup, I would like to create an daily or hourly snapshot from which I could quickly download files without having to untar on unzip. how could I set this up?

Palm
08-18-2001, 11:36 PM
You can add an extra hard drive and and download software called Flexbackup which will back up your file to the second drive.

node9
08-19-2001, 01:27 AM
Or
jus tset a cronjob to .tar.gz all your files into one file........ e.g. backup.tar.gz, and everyday, just download the .tar.gz onto your computer

But that could be alot of bandwidth hehe

e.g. 70mb .tar.gz file.... 70 x 30 days

Fremont Servers
08-19-2001, 01:27 AM
Hello Palm,

Can you post the url of Flexbackup?

I am interested in checking out this software/script.

SLN
08-19-2001, 02:05 AM
http://members.home.net/flexbackup/

NVB
08-19-2001, 08:24 AM
Originally posted by node9
Or
jus tset a cronjob to .tar.gz all your files into one file........ e.g. backup.tar.gz, and everyday, just download the .tar.gz onto your computer

What is the command to setup a cron job to .tar all the files with a directory and all its subfolders, once per day?

Mike the newbie
08-19-2001, 09:51 AM
Originally posted by NVB
I would like to backup my server on a daily basis with a cron job. There is under 100 MB worth of data. I want to do spend as little money as possible.

Here is something that I use. It may or may not be useful for your needs, depending upon the amount of data you use.

On the box I want to backup, I run the command:

tar -cf - usr home var | ssh backup@destinationbox "dd of=/home/backups/backup20010819"

That will tar the contents of the usr, home and var directories, open up a secure shell connection to the remote box, and place the tar file in the /home/backups directory on the remote box. All very secure.

While I don't use it in my setup, you may also be able to use the z option on tar to gzip up the file for reduced bandwidth usage.

You may have to tweak the commands to fit into your user/hostname scheme, just check out man ssh, man tar and man dd for the details you need.

Mike the newbie
08-19-2001, 11:21 AM
Originally posted by Mike the newbie

tar -cf - usr home var | ssh backup@destinationbox "dd of=/home/backups/backup20010819"


Typo alert - the command should be:


tar -cf - usr home var | ssh backups@destinationbox "dd of=/home/backups/backup20010819"



The user name "backups" should match the name of the directory in home. I left off the 's" originally.

smash
08-19-2001, 12:06 PM
Hi,

I use backup to a second HD. I chose this solution because I wanted the server to be back online as soon as possible if the hard disk failed..

Each hard-disks are identical and I created the same partitions on each of them. I use 'cpdup', a program mirroring filesystems (copies files that have been changed only). It is called everyday with a cron job. I also do not keep the /backup filesystem mounted, in case a hacker gets in and erase all mounted filesystems.

First HD:
/
/usr
/var
/backup/sites

Second HD:
/sites
/backup
/backup/usr
/backup/var

This way, the system files are used from the first HD and backed up on the second, while all the websites are on the second and backed on the first. This way both HD's are useful.

I also modified the boot process so if the system cannot mount one of the partitions, it will automatically try to mount the backup on the other disk. Of course, if the first Hard Disk fails, the system will not boot, but I'd simply have to swap the IDE cables on the motherboard and it would be ok.

Of course it would be way better to have SCSI raid system, but I can't afford it right now.


--
Cedric

StephenRS
08-19-2001, 12:39 PM
"Best way" =
Most reliable way?
Cheapest way?
Simplest way?

In your case, you imply cheapest. But backups are important enough to have at least a COUPLE solutions in place.
==========================

Since you have only 100MB, I suggest compress it as much as possible... and download it.

I would caution against the 2nd hard drive... at least as a SOLE solution.

At least make sure you make an off-site copy at least once a week (or whatever you consider to be acceptable maximum loss timeframe).

Nasty things can happen like:
-- Fire
-- ISP closes shop.
-- Major ISP outage, like days!
-- Operating system damages and your system won't boot... what good is data on 2nd drive (unless mirrored entirely). I have seen problems like this take days to sort out.

=========================

For MANY situations, focusing on reducing the data backup as much as possible is the key. Doing incremental style backups... for example: download a complete set of database records every 14 days -- but every 2 days download only the new/changed records.

Can take a little planning, but this way your backups can often be reduced to a praticial size that download-style backups are practical.

Good luck.

ho247
08-20-2001, 09:29 AM
If you didn't have RAID, and used the second hard drive backup solution, how often would you backup your site to your home computer's hard drive?

What if the site was say 100MB, you couldnt justify it enough to back that up every night, that would be a waste of bandwidth.

Would you do a download of the site to your hard drive, once a week, or once a month??

NVB
08-20-2001, 11:36 AM
Originally posted by Mike the newbie
the command should be:


tar -cf - usr home var | ssh backups@destinationbox "dd of=/home/backups/backup20010819"



What would be the command to backup multiple directories, storing the tar file in a new directory on the same hard drive?

Mike the newbie
08-20-2001, 12:37 PM
Originally posted by NVB



What would be the command to backup multiple directories, storing the tar file in a new directory on the same hard drive?

Just change the hyphen (which directs tar to put the output file to console) to the destination filename.
tar -cf /backups/backup20010819 usr home var
will backup the usr, home and var directories to the backup20018019 file in the backups directory. The backups directory should exist before the comand is run. The tar command (because of the c option) will create the file. man tar is your friend.

As with any backup scheme, make sure you can restore from your backups!


(aside: "same hard drive" is somewhat of a Windows file system concept. The hierarchical file system of *nix looks at the file system and disk structures a little differently.)

carpman
08-20-2001, 01:04 PM
This thread has been interesting, but what i would like to know is what dir to actually backup.

I am using WHM and Cpanel with reseller features in use.

I am not to bothered about home dir as this is the users responsibility.

I was thinking of using Flexbackup to remotely back up my server to local machine using my cable connection.


any thoughts

Mike the newbie
08-20-2001, 08:46 PM
Originally posted by carpman
This thread has been interesting, but what i would like to know is what dir to actually backup.


What directories you back up is quite dependent upon what scenario you expect to find yourself in when you need to do a restore.

In my situation, I plan to do a full OS restore from CD, then just get the data in /home back and also ssh and the /etc directory. Everything else, I'd rather recreate from scratch using the install logbook that I keep as I install things on the box.

My server is pretty much a hobby for me, so if it takes a few days to bring back to normal, that's fine.

You have to evaluate your situation and your restoration needs to tailor a backup plan that best suits your needs. StephenRS gave a few good pointers upthread a bit.

jks
08-20-2001, 09:59 PM
As always, I'll recommend doing your backups with rsync + ssh.

That gives you:

1. An easy way to do backups (it's one simple command)

2. Very efficient traffic wise (it only copies the parts of the files that has actually been changed)

3. Very easy to restore backups or part of backups (as they are not compressed or similar)

4. Due to SSH it's very secure, and can even be automated from cron.

The bad things:

1. It uses just as much disk space for the backup as for the original files (no compression).

HostingDirect
09-21-2001, 08:05 PM
I am using a WHM/CP3 box and I have a 2nd hard drive that I would like to use for back up. Where can I find more information on rsync such as the commands to do a backup and a restore?

Fremont Servers
09-24-2001, 03:13 PM
Originally posted by Palm
You can add an extra hard drive and and download software called Flexbackup which will back up your file to the second drive.

Will there be any problem if you use Flexbackup to backup data over 2GB?