Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Any way to make backups require less transient space?

Discussion in 'Data Protection' started by Ishware, Apr 12, 2016.

  1. Ishware

    Ishware Well-Known Member

    Joined:
    Nov 7, 2003
    Messages:
    193
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Panama City, FL
    cPanel Access Level:
    Root Administrator
    I've recently downgraded to a VPS from a Dedicated. Now, instead of loads of extra space, I only have a bit more. Nightly backups are sending me a nightly warning about disk space getting close to the limit.

    Is there any way to do backups differently? Can I write a script to trigger a backup for each account manually or something? I do have a remote target set up - it's actually another VPS (lots of space, minimal CPU/RAM, so perfect for keeping a daily+monthly backup).

    I know enough bash scripting to get myself in trouble. :) But if I can manually trigger a backup, I know that I can rsync it to my target. I'm willing to play with the new uapi, but while I can list backups, it doesn't look to me like I can :make: a backup. :/

    Any suggestions?
     
  2. Ishware

    Ishware Well-Known Member

    Joined:
    Nov 7, 2003
    Messages:
    193
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Panama City, FL
    cPanel Access Level:
    Root Administrator
    I forgot to look for /scripts/ solutions. And of course /scripts/pkgacct exists.

    I'll leave this thread up for anyone else who looks for an answer like this. I'll also share the bash script I'm working on when I get it done. :)
     
  3. Ishware

    Ishware Well-Known Member

    Joined:
    Nov 7, 2003
    Messages:
    193
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Panama City, FL
    cPanel Access Level:
    Root Administrator
    Here's what I have so far. I have it as an alias in .bash_aliases for now, but I plan to move it to the server and run via cron. I also will write a script later that will deal with previous backups, but for now, this is a start:

    Code:
    backupserver () {
            fdir=`date +%Y-%m-%d`
            ssh -t -n -o LogLevel=QUIET user@backupserver.ext "mkdir /backups/$fdir" &>> ~/.backups.$fdir.txt
        while read line; do
            echo "Packaging $line…"
            echo "__________________________________________________________________" &>> ~/.backups.$fdir.txt
            echo -e "$line:" &>> .backups.$fdir.txt
            ssh -t -n [EMAIL]root@mainserver.ext[/EMAIL] "/scripts/pkgacct $line --dbbackup=all /backups/$fdir" &>> ~/.backups.$fdir.txt
           
            echo "Transporting $line…"
            ssh -t -n root@mainserver.ext -t "scp /backups/$fdir/cpmove-$line.tar.gz user@backupserver.ext:/backups/$fdir/" &>> ~/.backups.$fdir.txt
            ssh -t -n root@mainserver.ext -t "rm /backups/$fdir/cpmove-$line.tar.gz" &>> ~/.backups.$fdir.txt
            echo -e "\n\n" &>> ~/.backups.$fdir.txt
        done < ~/.mainserveraccts.txt
    }
    
    Note that ~/.mainserveraccts.txt consists of a list of usernames I want to backup. As I create new accounts, I'll add them to the list.

    I also don't worry if the backups/[date] folder exists or not - it throws an error that it does if it does, and big whoop. Also, running this twice in one day will of course overwrite the backups, which may or may not be your desire. And you'll want to change user@backupserver.ext and root@mainserver.ext to match your two actual user@servers. And adjust the log name if you want.

    If you have suggestions/improvements, please share. :)
     
    #3 Ishware, Apr 12, 2016
    Last edited by a moderator: Apr 12, 2016
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,961
    Likes Received:
    1,821
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Ishware likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice