Skip to content

Fix a corrupted backups file

Raoul Bhatia edited this page Aug 14, 2020 · 3 revisions

Problem Description

In rare circumstances, your backups file in pc/hostName/backups might be corrupted and/or restarted from backup number #0.

The backups and backups.old file might then look something like shown below. Your pc/hostName directory will hopefully still contain the old backups, organized in individual sub-directories:

ls -altr pc/hostName/ | tail -n 15
drwxr-x--- 1 backuppc backuppc    396 Aug  3 07:26 5503
-rw-r----- 1 backuppc backuppc   4050 Aug  3 07:37 XferLOG.5503.z
drwxr-x--- 1 backuppc backuppc    568 Aug 12 00:44 5504
-rw-r----- 1 backuppc backuppc  14460 Aug 12 00:59 XferLOG.5504.z
-rw-r----- 1 backuppc backuppc      0 Aug 12 23:34 XferLOG.5505.z
drwxr-x--- 1 backuppc backuppc    568 Aug 12 23:47 5505
drwxr-xr-x 1 backuppc backuppc    226 Aug 13 00:01 ..
-rw-r----- 1 backuppc backuppc     65 Aug 13 02:21 backups.old
drwxr-x--- 1 backuppc backuppc    568 Aug 13 09:37 0
-rw-r----- 1 backuppc backuppc    125 Aug 13 09:37 backups
drwxr-x--- 1 backuppc backuppc   3998 Aug 13 09:37 .
drwxr-x--- 1 backuppc backuppc   3080 Aug 13 09:43 refCnt
-rw-r----- 1 backuppc backuppc 745080 Aug 13 09:43 XferLOG.0.z
-rw-r----- 1 backuppc backuppc   9479 Aug 13 13:00 LOG.082020
-rw-r----- 1 backuppc backuppc      0 Aug 13 13:14 LOCK
cat pc/hostName/backups
0       full    1597273203      1597304229      66263   231293732766    904     29562   43      30377251        0       0       0       0       3       35321   4433611 0           1
        rsync   0               4.4.0   139720  0
cat pc/hostName/backups.old
0       active  1597273203                                                                                              3                       0               1       rsync   0   4.4.0    58824   0

Steps to Take

Stop the backuppc process

systemctl stop backuppc

As the user backuppc, use BackupPC_fixupBackupSummary to recreate the backups file.

sudo -i -u backuppc
time BackupPC_fixupBackupSummary hostName; echo $?

Validate that you can restore from the previous backups (use your respective IDs, make sure you test both full and incremental backup restore!)

# Create temporary restore file with safe permissions
touch /tmp/restoretest.tar && chmod 600 /tmp/restoretest.tar

# Test full backup
BackupPC_ls -h hostName -n 3610 -s '/shareName' '/'
BackupPC_tarCreate -h hostName -n 3610 -s '/shareName/' '/' > /tmp/restoretest.tar && tar tvf /tmp/restoretest.tar

# Test incremental backup
BackupPC_ls -h hostName -n 5504 -s '/shareName' '/'
BackupPC_tarCreate -h hostName -n 5504 -s '/shareName/' '/' > /tmp/restoretest.tar && tar tvf /tmp/restoretest.tar

# Cleanup
rm /tmp/restoretest.tar

When verified good, restart backuppc

systemctl start backuppc

Further Reading