How to programmatically generate backups from command line as root?
Is there a way to programmatically create a cPanel backup from the Terminal if I'm root? I need to generate one on demand that can be restored via the WHM interface. So probably a .tar like we find each night in: /home/backup/2024-12-21/accounts
-
YES! Thank you for this link. This is what I'm after. Merry xmas. Thanks again.
0 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
Glad to hear it!
0
Please sign in to leave a comment.
Comments
11 comments