Paper Lantern for cPanel accounts is being retired this year. Find out more »
cPanel & WHM Version 102 has been released, and brings a slew of great updates. Take a look at what is included, and then upgrade today!

pkgacct: add feature to skip database data, but not database existence

Phillip Baker shared this idea 6 years ago
Completed

We have an existing, 3rd party backup solution that backs up the entire server and takes consistent mysql backups each time a system snapshot is taken. We run these backups 6 times a day.

In order to protect against customers accidentally deleting (or in the event that they wish to undelete) a cpanel account, we also use a script that fires every night to backup all cpanel account metadata by calling pkgacct for every account with "--skiphomedir" set. If a customer deletes a cpanel account, we restore the metadata using the cpmove file, and then seperately restore their files and database from our 3rd party backups.

The reality is, however, that we are creating cpmove files containing mysql data when it simply isn't necessary - this means more I/O and larger backups - using the existing --skipacctdb completely ignores the existence of mysql databases and users altogether, which isn't really much of a solution either.

I would like to request the addition of a variation on --skipacctdb (perhaps --skipacctdbdata) that still takes account of the existence of databases, and the credentials configured to access them, but does not actually dump the contents of the databases at the time of backup, and when restored simply creates empty databases. This shouldn't be too complicated to add; it's essentially like the regular backup - just without a mysqldump.

Best Answer
photo

The --dbbackup schema option to pkgacct should accomplish what you need. When provided, the database data is not included in the resulting cpmove file. However the database names, usernames, and permissions are included.

Replies (5)

photo
1

Are you looking to have it backup the schema and not the data, or just an empty file for the database?

photo
2

To be honest, either would be fine (as schemas are not going to require a lot of I/O or diskspace!), but I was thinking a completely empty, schemaless DB when I wrote this!

photo
1

This would be a real time saver, would love to see the option implemented.

photo
1

@cPanel Why is this topic still under open discussion and not yet implemented?

This would really speed up cpbackup and save a lot of disk space for anyone using any 3rd party backup solution that backs up the entire server and takes consistent mysql backups.

photo
2

The --dbbackup schema option to pkgacct should accomplish what you need. When provided, the database data is not included in the resulting cpmove file. However the database names, usernames, and permissions are included.

photo
1

This does indeed appear to generate a backup file without any mysql data inside it (i.e. switching from --skipmysql to --dbbackup schema does not significantly increase the size of the resulting cpmove file, and I can see the DB schemas inside the backup). It does rather give the impression that it's still doing a full mysqldump even though it's just dumping out the table schemas because it quotes a mysqlsize at the end which matches the populated database size rather than just the schemas it actually stored.

Thanks for sharing. I am satisfied this meets the objective of my original request.

photo
2

I'm glad to hear the option meets your needs! In reviewing the --dbbackup option, it appears we added it not long after this feature request was filed but the request was not updated with that fact. Case CPANEL-2458 added the option to version 54 of cPanel & WHM.

photo
1

Thanks, --dbbackup_mysql schema is exactly what we need: all databases, users and their permissions, but without any data in db tables.

photo
Leave a Comment
 
Attach a file