The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Whats best way to Backup all CPanel accounts and databases to my PC

Discussion in 'General Discussion' started by infocom, Nov 22, 2006.

  1. infocom

    infocom Member

    Joined:
    Nov 21, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    Before I start, my home PC is Windows XP...

    I want to backup all my CPanel accounts and databases to my home PC (in addition to my hosting provider making backups).

    Now I can see various software out there. I tried Site Backup CP and it looks good. BUT the software, and Cpanel iteslf, seem to make FULL backups. This will have a very bad impact on my bandwidth limits as I want to do it every day.

    So I am looking into rsync. I got rsync working to backup the files, and it will only backup CHANGED files, and delete files deleted from the server, so making a complete mirror. Great! Except I can't see how to do this for the MySQL databases and anything else I need to do (emails, aliases, parked/addon domains etc.).

    So does anyone know a good solution I can use to backup all my changed files PLUS my databases and any other important CPenal data to my home PC without having to do a FULL backup every time. I am using Windows XP so this may exclude any bash scripts I can see that are available.

    Thanks

    Laurie
     
  2. SoftDux

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    If you have managed to get rsync to work, congrats :)

    It's an awesome tool.

    Here's the idea:

    Use mysqldump, from the commandline, via a crontab to dump the DB, preferabbly in your root folder so that it can't be downloaded. Then, after that command has run, in the same script run rsync to sync your website, and the dumbed DB to your PC. This way you could automate the whole process.

    The otherway, is to setup MySQL on your home PC, and look @ doing a master - slave replication, where the MySQL on your website will be the master, and the one on your PC will be the slave. The MySQL on your PC will then automatically keep all DB transactions in sync.

    hth
     
  3. infocom

    infocom Member

    Joined:
    Nov 21, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for replying. I just came back here to post my current solution which is quite similar... yes rsync is great (although difficult to get working) as it only does a backup of changed files! Seeing as there's so many image files in shopping carts and such it would be really bad for full backups every day.

    If anyone knows how to backup the email accounts, aliases and anything else I need to do to backup Cpanel in addition to this I would be grateful.

    So here's my current solution, using SSH and rsync.

    I use a .cmd file on Windows PC with Windows based command scripts. This way I can then schedule in the file to run. So I called my file "backup.cmd". Or you can call it a .bat file.

    The scripts I use basically first use SSH to run mysql dump to dump the database file, then use rsync to synchronise the files with the files on my PC.

    So I installed SSH and rsync on my Windows PC, and then setup private and public keys so I dont need a password. Instructions for all this here: http://optics.ph.unimelb.edu.au/help/rsync/rsync_pc1.html

    Then once rsync and ssh is installed on your PC you can run the file. After playing around with it for a while I got the following command lines working and placed them in the .cmd or .bat file:-


    Code:
    ssh -i private_key_file %CPANEL_USERNAME%@your_domain.com "mysqldump -u %CPANEL_DATABASE_USERNAME% --password="%CPANEL_DATABASE_PASSWORD%" %CPANEL_DATABASE% > %CPANEL_DATABASE%.sql"
    
    rsync -avzp --stats --delete-before --force -e "ssh -i private_key_file" %CPANEL_USERNAME%@your_domain.com:/home/%CPANEL_USERNAME%/ /cygdrive/f/%CLIENT_DOMAIN_NAME%/
    
    The text enclosed in % % are variables that can be set with SET %CPANEL_USERNAME%=cpanel_username or just insert your values here direct.

    Be really careful with rsync though. Especially when using --delete commands, you may delete files on the server or your PC with incorrect use. So play around with a test account first.
     
  4. SoftDux

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    Your email is also stored in your account, under a folder called /email :)
     
Loading...

Share This Page