Restored database missing records, and, failed to backup database : pg_dump failed :

SYSTEM INFORMATION
OS type and version Rocky Linux 8.10
Usermin version 2.102
Virtualmin version 7.30.3

I had initially carried out a virtualmin backup and restore and everything reported as having completed successfully, however on checking the PG database I found there were missing records. So I thought I’d manually backup and restore the DB instead, however on trying to do that I get:

Failed to backup database : pg_dump failed :
bash: /home/db_repository/name.sql: Permission denied
Scheduled backup for database left disabled.

I tried to set it to a schedule too, but on checking there is not backup present several minutes after the scheduled time.

I vaguely recollect experiencing something similar a while ago, but can’t remember now how we got around it. Anyone have any ideas?

Sounds like you’re trying to backup to a file or directory owned by root as a non-root user, like the domain owner user.

1 Like

Thanks Joe, I had to made the directory writeable with:

chmod 777 /home/db_repository

That seems like a risky choice. But, I guess as long as the files aren’t readable/writable by everyone it’s fine.

1 Like

Do you have an alternative suggestion Joe? I tried to chown the directory for the same user as the account but was still getting a failure…

Update: the manual db dump and restore worked with all records intact. Not sure if the team want to look into this but the concerning thing is if we had to rely on a virtualmin backup after a failure we would have lost data : /

Do the backups (Virtualmin > Backup & Restore > Scheduled Backups) use the same command as the manual dump (Virtualmin > Domain > Edit Databases > Manage > Backup) when dumping the PG database?

Here’s what I used to create the backup (which was used for restore - and what had records missing):

virtualmin backup-domain --domain domain.tld --dest /home/backups/domain.tld.tar.gz --all-features

Which on the new server was then restored with:

virtualmin restore-domain --source /home/backups-for-restore/domain.tld.tar.gz --all-features --domain domain.tld

Couple more things to report:

The user that creates the backup is postgres so creating the /home/db_repository/ folder then:

chown -R postgres:postgres db_repository 

Successfully carries out the backup as expected. However, since the virtualmin scheduled backups only backup up domain accounts that means these backups would not get backed up via the scheduled backups, so naturally you’d want to specify the backup directory as:

/home/domain-account/db_repository/

But you then get the same failure when attempting a backup, even if db_repository has been chown to postgres:postgres or even if you chmod 777 /home/domain-account/db_repository.

I don’t think I have proper context here.

Are you saying that when you do a Virtualmin backup (not a PostgreSQL dump independent of Virtualmin, either in the CLI or via the Webmin PostgreSQL module) you have this permission problem and this directory is only used for Virtualmin backups (and not any other kind of backup using other tools)? If you’re using this directory for multiple kinds of backup (Virtualmin backups and some other kind of database dump), that would be a complicated idea, maybe a bad one.