Symptoms
When investigating the backup logs in /usr/local/cpanel/logs/cpbackup/ you are presented with this error:
[2020-09-15 02:00:03 +0200] info [backup] Setting I/O priority to reduce system load: best-effort: prio 6
[2020-09-15 02:00:04 +0200] info [backup] Pruning metadata for backup at /backup/$DATE/
[2020-09-15 02:00:04 +0200] info [backup] Creating metadata index for backup at /backup/$DATE/
Cpanel::Exception::IO::FileCreateError/(XID bpntvd) The system failed to create the file “/backup/$DATE/accounts/$NAME.master.meta” with permissions “0600” (as EUID: 0, EGID: 0 0) because of the following error: No such file or directory
at /usr/local/cpanel/Cpanel/FileUtils/Write.pm line 197.
Cpanel::FileUtils::Write::_write_to_tmpfile("/backup/2020-09-15/accounts/.master.meta", "{\x{a} \"Status\" : \"Successful\",\x{a} \"backup\" : {\x{a} \"backup_i"..., 384, CODE(0x24d56e0)) called at /usr/local/cpanel/Cpanel/FileUtils/Write.pm line 127
Cpanel::FileUtils::Write::overwrite("/backup/2020-09-15/accounts/.master.meta", "{\x{a} \"Status\" : \"Successful\",\x{a} \"backup\" : {\x{a} \"backup_i"..., 384) called at /usr/local/cpanel/Cpanel/FileUtils/Write/JSON/Lazy.pm line 104
Cpanel::FileUtils::Write::JSON::Lazy::write_file_pretty("/backup/2020-09-15/accounts/.master.meta", HASH(0x3aba8a0), 384) called at /usr/local/cpanel/Cpanel/Backup/Metadata.pm line 199
Cpanel::Backup::Metadata::create_meta_master("/backup/2020-09-15", 2) called at /usr/local/cpanel/bin/backup line 379
bin::backup::run("bin::backup") called at /usr/local/cpanel/bin/backup line 120
[2020-09-15 02:00:04 +0200] info [backup] Final state is Backup::Failure (0)
[2020-09-15 02:00:04 +0200] info [backup] Sent Backup::Failure notification.
Description
The backup seems to fail because the backup process can not create a metadata index temporary file for the backup. If there is enough space on the backup partition, then this usually means that the backup process does not have proper permissions to write to the backup directory. In most cases, the issue is that the partition that has been mounted to the backup directory has been mounted with only read-only options (ro). To confirm this, you need to first identify the backup directory like this:
whmapi1 backup_config_get | grep -i backupdir
backupdir: /backup
Then you need to search for the mount options for the partition associated with that directory. You can search for that information using this command: (Replace $BACKUPDIR with the name of the backup directory from the previous command):
mount -l | grep -i "$BACKUPDIR"
- - - - - - - - - - - - - - - - - - - - - - - - - -
mount -l | grep -i "\/backup"
/dev/sdb1 on /backup type ext4 (ro,relatime,seclabel,errors=remount-ro,data=ordered)
As you can see the option "ro" appears in the mount option for the partition /dev/sdb1 and this means that the file system is read-only and the backup process fails as a result of this issue.
Workaround
You need to remount the file system with read-write permissions.
sudo mount -o remount,rw /partition/identifier /mount/point