View Full Version : Backup -- better way of doing it than "the WH way"

01-29-2005, 04:59 PM

I love the ease of use with the backup solution WH has to offer, but there is one thing I do not like about it : your whole VPS is down until you have completed the download of your backup file. Is there any better free backup solution out there?

I do not know *nix commands very well, but I didn't know if there was a way to zip your whole VPS and then download it via FTP or what have you.. that way i'm assuming your VPS will not be down during the file transmission.

Thanks for any advice,


01-30-2005, 01:28 AM
Which parts of your server do you want backed up?

01-30-2005, 08:01 AM
You may use the tar and gzip commands in ssh to compress a specific directory.

01-30-2005, 08:02 AM
Most importantly everything under :


.. if the whole VPS can't be done "easily" ..



01-30-2005, 08:21 AM
Welll, you'll find that something like (untested):

$ tar czf /site-backup.tgz /var/www/ /ftp/pub/ /etc/mail/

will do that quite easily. You'll end up with a file in the root called 'site-backup.tgz'

01-30-2005, 11:32 AM
Well I just gave Jalal's suggestion a try and it worked pretty well. Now I only did it on one a directory for a subdomain I have been working on but it zipped them in no time and saved the file in root.

Now my question is... I wonder if you could add alias commands to the .bashrc to make things even easier. My thought is you could have something like this:

alias back_www="tar czf /www-backup.tgz /var/www/"
alias back_pub="tar czf /pub-backup.tgz /ftp/pub/"
alias back_mail="tar czf /mail-backup.tgz /etc/mail/"
alias back_all="tar czf /site-backup.tgz /var/www/ /ftp/pub/ /etc/mail/"
I haven't edited a .bashrc file for quite some time. Do you have to restart if you do? I can't rember from the last time I did it.

The reason I like this is because as I mentioned above I tested it on a new subdomain I have been working on and last night I was makeing changes via my laptop. This morning it was very easy to zip those changes up and download them to my main computer. :)

Thanks jalal for the idea and rbayless for asking the question.

01-30-2005, 12:27 PM
Hi Shawn

Your idea will work. You don't need the '$' in the command line though.


alias back_www="tar czf /www-backup.tgz /var/www/"

should to the job.

You should log out of the shell and back in to have the aliases reset from the .bashrc. No need to restart the server.

01-30-2005, 02:39 PM
Thanks Tim,
I'll fix my post so folks won't get confused. That's what I get for using cut and past and not proof reading close enough. :)

01-31-2005, 07:39 AM
One thing. I don't know if you plan on putting this in a cron job or not. If you are, the alias probably will not work because you .bashrc is not sourced when running a cron. So you'd probably be better off writing a script.

02-03-2005, 05:55 PM
Welll, you'll find that something like (untested):

$ tar czf /site-backup.tgz /var/www/ /ftp/pub/ /etc/mail/

will do that quite easily. You'll end up with a file in the root called 'site-backup.tgz'

Thank you jalal and others for your response!

I am assuming, like the example above, if I put in /ftp/pub/ it will backup all the child subdirectories underneath /pub/ ? Also, is there a limit to the # of directories the tar command line will take?



02-04-2005, 02:40 AM



You can also put the list of directories into a normal text file (one per line) and call that like so:
'tar czf /backup.tgz -T filelist.txt'

Tar is one of the most useful tools on linux systems, you can find more info around the web.

WestHost - MMellor
02-09-2005, 11:21 AM
This is a great tutorial! Thanks for all the help everyone!