Web Hosting Forum Login
Not a member yet? Sign up

Backing up your cPanel accounts to a remote location with Rsync

  • HOME
  • FORUMS
  • WEB DESIGN
  • WEB HOSTING OFFERS
  • ADVERTISING
  • FIND A HOST
  • WEB HOSTING
  • QUICK MENU
  • REGISTER HERE - Join us for FREE
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2016
    Location
    Hertfordshire, UK
    Posts
    762
    Thanks
    39
    Thanked 158 Times in 134 Posts
    Thumbs Up/Down
    Received: 348/3
    Given: 128/3

    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/ root@backupserver: /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
    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
    253
    Thanks
    23
    Thanked 11 Times in 11 Posts
    Thumbs Up/Down
    Received: 109/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?
    Energized Web Hosting
    Shared Hosting | Reseller Hosting | VPS | Domain Names
    Ministry Web Hosting

  4. #3
    Join Date
    Jul 2016
    Location
    Hertfordshire, UK
    Posts
    762
    Thanks
    39
    Thanked 158 Times in 134 Posts
    Thumbs Up/Down
    Received: 348/3
    Given: 128/3
    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
    https://www.ljshost.com

Newer Threads

  1. David Beroff
    Gecko
    Replies: 8 | Views: 285
    Last post by Gecko, 02-14-2017, 04:43 AM
  2. Paul Wellner Bou
    Paul Wellner Bou
    Replies: 0 | Views: 193
    Last post by Paul Wellner Bou, 12-31-2016, 03:07 PM
  3. Maxoq
    EcommIndiaCloudIT
    Replies: 2 | Views: 603
    Last post by EcommIndiaCloudIT, 12-31-2016, 06:04 PM
  4. Dopani
    Enom vs Resellerclub
    By Dopani in forum Domain Names
    VictorVictories
    Replies: 8 | Views: 401
    Last post by VictorVictories, 02-17-2017, 02:44 PM
  5. Dopani
    TSmith
    Replies: 3 | Views: 554
    Last post by TSmith, 01-01-2017, 11:12 AM

Older Threads

  1. Reyansh
    VictorVictories
    Replies: 9 | Views: 1053
    Last post by VictorVictories, 02-07-2017, 12:22 PM
  2. Reyansh
    ankitmaharjan
    Replies: 12 | Views: 333
    Last post by ankitmaharjan, 02-13-2017, 01:52 PM
  3. fwh
    IgorG
    Replies: 12 | Views: 381
    Last post by IgorG, 01-10-2017, 07:48 AM
  4. Steve32
    archhosting
    Replies: 6 | Views: 751
    Last post by archhosting, 02-07-2017, 10:51 AM
  5. Steve32
    Buying Looking for link building services
    By Steve32 in forum Link Sales
    Steve32
    Replies: 0 | Views: 158
    Last post by Steve32, 12-31-2016, 09:15 AM

Latest Threads

  1. austenite
    DaRecordon
    Replies: 8 | Views: 67
    Last post by DaRecordon, Today, 04:14 AM
  2. HosterDaddy
    HosterDaddy
    Replies: 0 | Views: 34
    Last post by HosterDaddy, Yesterday, 03:58 PM
  3. HosterDaddy
    HosterDaddy
    Replies: 3 | Views: 46
    Last post by HosterDaddy, Today, 04:20 AM
  4. HosterDaddy
    HosterDaddy
    Replies: 7 | Views: 79
    Last post by HosterDaddy, Yesterday, 08:22 PM
  5. HosterDaddy
    HosterDaddy
    Replies: 0 | Views: 24
    Last post by HosterDaddy, Yesterday, 12:41 PM

Similar Threads

  1. TheCompWiz
    hfav
    Replies: 5 | Views: 771
    Last post by hfav, 01-19-2017, 06:30 PM
  2. HostXNow
    HostXNow
    Replies: 0 | Views: 228
    Last post by HostXNow, 12-08-2016, 09:38 PM
  3. HostPace
    HostPace
    Replies: 0 | Views: 456
    Last post by HostPace, 07-01-2016, 02:39 PM
  4. The Overseer
    Starfire
    Replies: 5 | Views: 970
    Last post by Starfire, 02-13-2015, 02:04 AM
  5. Holly Nicole
    Holly Nicole
    Replies: 0 | Views: 718
    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!