Skip to main content

How to programmatically generate backups from command line as root?

Comments

13 comments

  • Benjamin D.

    YES! Thank you for this link.  This is what I'm after.  Merry xmas.  Thanks again.

    0
  • Benjamin D.

    Ahhh... Again, it defies all logic and makes it unusable for at least 2 of my server's accounts.  I don't understand who thought this was a good idea but that script allows you to exclude just about every single thing from an account, EXCEPT what's in /etc/cpbackup-exclude.conf ... WHY?!

    0
  • cPRex Jurassic Moderator

    pkgacct ignores any files from the exclude configuration as it's designed to be use to migrate an account to another system.

    You can manually run "/usr/local/cpanel/bin/backup --force" to force a run of the backup system, which will follow all the configurations in both WHM and the exclude file, but that will run for all accounts.

    0
  • Benjamin D.

    Is there a way to add the option to /usr/local/cpanel/scripts/pkgacct so that it packages the account exactly as it would when the nightly backup process runs? Basically, you guys only need to add an option to the command like: --skip-excluded-files

    Oh, I also had another related question: What is the command (if it exists) to also generate the system backup package? You know the one that gets created into /home/backup/2024-11-11/system/

    0
  • cPRex Jurassic Moderator

    Actually, and I'll say I haven't tested this one before, we have this flag for pkgacct:

    --userbackup

    with "run in userbackup mode" as the description - that sounds like it might work for your situation!

    (fun fact - most cPanel commands you can run with no flags and see all the options, so running "/scripts/pkgacct" will show you all the flags it has available.)

    0
  • Benjamin D.

    The documentation says nothing about --userbackup honoring the /etc/cpbackup-exclude.conf exclusions.  I will have to test it with an account that has some exclusions later and report what I found here.  Please check my other question in my previous post (sorry, I edited it while you were posting this last answer)

    0
  • cPRex Jurassic Moderator

    Unfortunately there is no separate command for the system backup portion - the only way to get that stuff is through the main /usr/local/cpanel/bin/backup command.

    0
  • Benjamin D.

    Yes, but that does ALL the server accounts.  WHM needs to improve and allow sysadmins to do just the system "account" by itself.  I guess I could technically just rsync or disk image the root partition without the /home directory, but that would not be transferable nor would WHM want to restore that.

    0
  • Benjamin D.

    Alright so I figured I might as well just try it now and guess what: --userbackup does EXACTLY what I needed! It generates a backup honoring the /etc/cpbackup-exclude.conf exclusions.  PERFECT.  Thanks.

    0
  • cPRex Jurassic Moderator

    Glad to hear it!

    0
  • Serb

    Hmm, interesting... 

    Question for cPRex - what is the difference in output / archive itself when using --backup  vs --userbackup parameters?

    Is there any?

    Just trying to figure out which one is a better fit for what we need it for (in case of a server issue and OS needing to be reloaded / installed fresh or having to use these backups to restore the site on a new server).

    Also, how can we specify a custom directory in which to create these backups? Where do they get stored by default and can that be overridden by one of these parameters somehow (I don't see anything on that documentation page about that)?

    Thanks!

    0
  • cPRex Jurassic Moderator

    Serb - mainly just where it places the file.  --userbackup puts it in the user's home directory, while --backup puts it in the current working directory where you run the command.

    That may also help answer your last question.

    0

Please sign in to leave a comment.