Restoring deleted files from backup


Well-Known Member
Jan 20, 2008
CPanel Community,

I am running daily incremental backups plus weekly and monthly backups.

If a user deletes a file, how do I restore the file if the daily backup has already run?

I can't find the file in the last weekly backup because it was created after the last weekly backup was created.

I am used to creating separate daily incremental backups, so that each backup contains the files that were created or changed in the past 23-hours. CPanel seems to create only a daily full backup by making an incremental copy on top of a full copy. Deleted files appear to be removed from the daily backup.

The same situation occurs when a user wants a database restored. The database changes every day, so the last weekly backup won't contain the recent changes and the daily backup contains the last version. The user invariably wants the next to last version.




Well-Known Member
Jan 20, 2008
I found the rsync options in the cpbackup script:

my $rsyncopts = '-rlptD';

#recusive, copy symlinks as symlinks, preserve permissions,
#preserve times, preserve devices

Also, the script add "--delete" to almost every usage of rsync.

It appears to be missing -b for backups.

Can I add it?


-b, --backup make backups (see --suffix & --backup-dir)
--backup-dir=DIR make backups into hierarchy based in DIR
--suffix=SUFFIX backup suffix (default ~ w/o --backup-dir)

-b, --backup
With this option, preexisting destination files are renamed as each file is transferred or
deleted. You can control where the backup file goes and what (if any) suffix gets appended
using the --backup-dir and --suffix options.

Note that if you don't specify --backup-dir, (1) the --omit-dir-times option will be implied,
and (2) if --delete is also in effect (without --delete-excluded), rsync will add a "protect"
filter-rule for the backup suffix to the end of all your existing excludes (e.g. -f "P *~").
This will prevent previously backed-up files from being deleted. Note that if you are supply-
ing your own filter rules, you may need to manually insert your own exclude/protect rule some-
where higher up in the list so that it has a high enough priority to be effective (e.g., if
your rules specify a trailing inclusion/exclusion of '*', the auto-added rule would never be

In combination with the --backup option, this tells rsync to store all backups in the speci-
fied directory. This is very useful for incremental backups. You can additionally specify a
backup suffix using the --suffix option (otherwise the files backed up in the specified direc-
tory will keep their original filenames).

This option allows you to override the default backup suffix used with the --backup (-b)
option. The default suffix is a ~ if no --backup-dir was specified, otherwise it is an empty