Web Hosting Forum Login
Not a member yet? Sign up

Backing up your cPanel accounts to a remote location with Rsync

  • FORUMS
  • WEB DESIGN
  • WEB HOSTING OFFERS
  • ADVERTISING
  • WEB HOSTING
  • REQUEST A HOST
  • BEST WEB HOSTING
  • QUICK MENU
  • REGISTER HERE - Join us for FREE
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2016
    Location
    Hertfordshire, UK
    Posts
    888
    Thanks
    40
    Thanked 176 Times in 147 Posts
    Thumbs Up/Down
    Received: 442/3
    Given: 136/4

    Lightbulb Backing up your cPanel accounts to a remote location with Rsync

    Backing up your cPanel accounts to a remote location with Rsync


    WHM supports FTP transfer for backups to a remote location but not Rsync, if you would like to use Rsync for transfer here is how you do it, several plugins and paid for solutions are available for Rsync remote backups but with a couple of simple scripts you can Rsync yourself for free.

    Create and Rsync Full Account Backups

    These backups can be used to restore whole accounts or you can extract individual files from the archive to restore a specific file, email or database. The whole process is completed by using two scripts.

    Create the backup directory as root: mkdir /rsync_backups


    Script 1 - Packaging accounts

    Create a file called packaccounts.sh and add the following to the file

    Code:
    #!/bin/sh
    cat /var/cpanel/users | while read a; do
    /scripts/pkgacct $a /rsync_backups/
    done
    Run the script as a cron job

    crontab -e

    Add the following to bottom of the file

    0 1 * * * /root/packaccounts.sh

    Everyday at 1:00am your account will be packaged and ready to Rsync.

    Note: this will create the backup files in the /rsync_backups/ directory, ensure more than enough space is available before running the script.

    Make the file excutable:
    Code:
    chmod +x packaccounts.sh
    Change permissons so the file can only be excuted by root:
    Code:
    chmod 700 packaccounts.sh
    Move the file to /root:
    Code:
     mv packaccounts.sh /root/
    An alternative to using the packaging script is to use the WHM backup manager but make sure the destination for the backups is /rsync_backups/

    Script 2 - Rsync the files to the remote server and delete backups

    Code:
    #!bin/sh
    rsync -avz  --delete-after /rsync_backups/ [email protected]: /home/backup/
    Make the file excutable:
    Code:
    chmod +x packaccounts.sh
    Change permissions so the file can only be executed by root:
    Code:
    chmod 700 rsync_accounts.sh
    Move the file to /root/:
    Code:
    mv packaccounts.sh /root/

    As root ad the cron job

    Code:
    crontab -e
    Add the following to bottom of the file

    Code:
    0 4 * * * /root/rsync_accounts.sh
    Save and exit the cron file

    That’s it you’re all done everyday at 4:00am rsync will sync the backup files to the remote location and delete the backups on the source server to free up space. It is recommend that you run the packaging script first and see how long it takes to complete as you want Rsync to for example an hour later.
    Web Hosting | Reseller | VPS
    30 Day Money Back Guarantee | cPanel | 365 Day UK Support | Free Trial
    https://www.ljshost.com

  2. The Following 2 Users Say Thank You to LJSHost For This Useful Post:
    David Beroff (12-31-2016),MooseLucifer (12-31-2016)

  3. #2
    Join Date
    Dec 2016
    Location
    Midwest USA
    Posts
    254
    Thanks
    23
    Thanked 11 Times in 11 Posts
    Thumbs Up/Down
    Received: 114/0
    Given: 35/0
    LJSHost, interesting way to do this. I just use the builtin backup with WHM, but can see how rsync may be a better solution.

    What is the reasoning for doing it this way and not the builtin backup process?

  4. #3
    Join Date
    Jul 2016
    Location
    Hertfordshire, UK
    Posts
    888
    Thanks
    40
    Thanked 176 Times in 147 Posts
    Thumbs Up/Down
    Received: 442/3
    Given: 136/4
    Quote Originally Posted by energizedit View Post
    LJSHost, interesting way to do this. I just use the builtin backup with WHM, but can see how rsync may be a better solution.

    What is the reasoning for doing it this way and not the builtin backup process?
    Yes, it essentially does exactly what the builtin backup system does it just uses Rsync. One way is not better than the other it's just another option.
    I just like writing scripts that do stuff
    Web Hosting | Reseller | VPS
    30 Day Money Back Guarantee | cPanel | 365 Day UK Support | Free Trial
    https://www.ljshost.com

  5. #4
    Join Date
    Feb 2017
    Posts
    52
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Thumbs Up/Down
    Received: 27/0
    Given: 17/0
    interestingly any of you use legacy backup configuration in whm?
    HostGliders **Your Hosting partner**

    Amazing offers|| 50% OFF on Shared && Reseller plans || Budget vps||Domain names

  6. #5
    Join Date
    Mar 2017
    Posts
    54
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Thumbs Up/Down
    Received: 10/2
    Given: 0/0
    thanks a lot, we are using a third party tool for backups + cpanel backups but this seems more reliable !...

Newer Threads

  1. David Beroff
    Mujkanovic
    Replies: 16 | Views: 1274
    Last post by Mujkanovic, 06-10-2017, 05:16 PM
  2. Paul Wellner Bou
    Paul Wellner Bou
    Replies: 0 | Views: 437
    Last post by Paul Wellner Bou, 12-31-2016, 03:07 PM
  3. Maxoq
    EcommIndiaCloudIT
    Replies: 2 | Views: 1323
    Last post by EcommIndiaCloudIT, 12-31-2016, 06:04 PM
  4. Dopani
    Enom vs Resellerclub
    By Dopani in forum Domain Names
    HostYourNet-DR
    Replies: 30 | Views: 1985
    Last post by HostYourNet-DR, Yesterday, 06:56 PM
  5. Dopani
    TSmith
    Replies: 3 | Views: 1182
    Last post by TSmith, 01-01-2017, 11:12 AM

Older Threads

  1. Reyansh
    VictorVictories
    Replies: 9 | Views: 1680
    Last post by VictorVictories, 02-07-2017, 12:22 PM
  2. Reyansh
    NuWebHosting
    Replies: 15 | Views: 1185
    Last post by NuWebHosting, 02-26-2017, 08:16 AM
  3. fwh
    IgorG
    Replies: 12 | Views: 1048
    Last post by IgorG, 01-10-2017, 07:48 AM
  4. Steve32
    hostinfuse
    Replies: 13 | Views: 2546
    Last post by hostinfuse, 05-31-2017, 05:45 PM
  5. Steve32
    Buying Looking for link building services
    By Steve32 in forum Link Sales
    Steve32
    Replies: 0 | Views: 457
    Last post by Steve32, 12-31-2016, 09:15 AM

Latest Threads

  1. LarsJ
    LarsJ
    Replies: 0 | Views: 31
    Last post by LarsJ, Today, 01:21 AM
  2. rad-jason
    djsmiley2k
    Replies: 3 | Views: 20
    Last post by djsmiley2k, Today, 01:58 AM
  3. Kaz Wolfe
    VirtuBox
    Replies: 1 | Views: 25
    Last post by VirtuBox, Yesterday, 05:35 PM
  4. hostslim
    hostslim
    Replies: 0 | Views: 38
    Last post by hostslim, Yesterday, 08:30 AM
  5. hostslim
    hostslim
    Replies: 0 | Views: 26
    Last post by hostslim, Yesterday, 08:30 AM

Similar Threads

  1. HostPace
    HostPace
    Replies: 2 | Views: 685
    Last post by HostPace, 06-03-2017, 01:47 AM
  2. TheCompWiz
    hfav
    Replies: 5 | Views: 1549
    Last post by hfav, 01-19-2017, 06:30 PM
  3. HostXNow
    HostXNow
    Replies: 0 | Views: 553
    Last post by HostXNow, 12-08-2016, 09:38 PM
  4. The Overseer
    Starfire
    Replies: 5 | Views: 1100
    Last post by Starfire, 02-13-2015, 02:04 AM
  5. Holly Nicole
    Holly Nicole
    Replies: 0 | Views: 904
    Last post by Holly Nicole, 09-28-2013, 07:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Web Hosting Forum

ForumWeb.Hosting is a web hosting forum where you’ll find in-depth discussions and resources to help you find the best hosting providers for your websites or how to manage your hosting whether you are new or experienced. You’ll find it all here. With topics ranging from web hosting, internet marketing, search engine optimization, social networking, make money online, affiliate marketing as well as hands-on technical support for web design, programming and more. We are a growing community of like-minded people that is keen to help and support each other with ambitions and online endeavors. Learn and grow, make friends and contacts for life.

Community

The world's smartest hosting providers come here to discuss & share what's trending in the web hosting world!
Copyright ©2017, ForumWeb.Hosting. All rights reserved. Web Hosting Forum for webmasters, web hosting providers, designers and web developers.

Welcome to Forum Web Hosting

The World's Number 1 Web Hosting Community, Reviews & Services

Log in!

Continue with Facebook
Continue With Email. By signing up you indicate that you have read and agree to the Terms of Service and Privacy Policy.

Sign in Manually

Need an account? Sign up now!