Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running WHM/cPanel and I would like to make my own backup methods than what WHM is offering.

What I need to do is make backups each users public_html directory (/home/username/public_html/) and MySQL information then transfer those as it is into my backup server (SSH not FTP).

I just don't know how to make script like this?? Or is there one allready? I don't know if this hard or easy to do so could someone give me little kickstart! :)

Oh and I'm running CentOS 5.3 x86_64, Apache 2.2, PHP 5.2.11, cPanel 11.24.2 (<- not in backup server)

Thanks for all help!

share|improve this question

3 Answers 3

Sure, there's plenty of options out there for taking non-sucky backups. You can write a script around rsync, use an existing rsync-based backup system (I use dirvish, but it's probably beyond what you need or are willing to setup), or you can use something like rdiff-backup (which we use at work). I've heard some good things about backuppc, too. There are literally hundreds of backup systems out there; picking one is mostly a matter of throwing a dart.

share|improve this answer

Something basic and somewhat prone to error would be to do:

#!/bin/bash

for i in `ls /path/to/public_html`; do
    echo "Backing up ${i}"
    tar -cjvf /path/to/backupfolder/${i}.tar.gz ${i}
    scp /path/to/backupfolder/${i}.tar.gz username@backupserver:/backup/location/
    rm /path/to/backupfolder/${i}.tar.gz
done;

And for backing up each mysql database, you could do something along the lines of:

#!/bin/bash

for i in `mysql -uroot -ppassword --batch -e "show databases" | grep -v "Database"`; do
    mysqldump -uroot -ppassword --single-transaction ${i} > /path/to/dbbackup/${i}.sql
    scp /path/to/dbbackup/${i}.sql username@backupserver:/backup/location/
    rm /path/to/dbbackup/${i}.sql
done;

Obviously this is not an optimal/secure solution, and also does not contain any timestamp information. It also assumes you have public keys between your host computer and your backup computer.

Also, I personally would not use this method ;)

share|improve this answer

First, please describe why cPanel's backup method is not sufficient for you. That way we can understand your problem better.

Also, I'd recommend you look into existing backup software, rather than rolling your own. There are many recommended solutions; e.g. Areca backup for small home backup, or Amanda for large installations, to name just few; just look here or on Google.

That said, you can just script SFTP transfers using most command line SFTP tools (e.g. the standard sftp tool, or curl). Try it, and ask again if there are problems.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.