After a sudden shutdown backup restarts from scratch

Hi,

I’m testing Restic and really like it so far.

Restic was running for more than 3 hours on my Windows PC to backup my data to an external USB drive, and I guess I’ve probably closed inadvertently the PowerShell window. At least I found the program closed, I don’t know if’s a program crash or a mistake.

So I started again Restic, hoping that it would restart from the point where it has been aborted. But nope, it restarts the backup from scratch…

After a sudden shutdown, can’t Restic have the logic to restart the backup from where it was?

Well, kind of :grin:

For every backup run, restic basically does 2 things:

  1. Scan for all the files which need to be included for this backup
  2. Chunk the files and save them to the repository

The first part has to be run always as restic needs to have accurate information (files might have changed since last backup run) of all the files that you want to backup. This step might take some time if there is no ‘parent’ snapshot. A ‘parent’ snapshot is a previous snapshot of same ‘type’ (usually same hostname and path). Once there is a parent snapshot to rely on, the scan for new/changed files is pretty fast.

In the 2nd step all files are saved to the repository (local or remote). Restic checks if a file (or parts of it) has already been saved to the repository. If the files already exists nothing new is (uploaded and) saved except for metadata of the file. If the file is new or changed it will (uploaded and) saved as usual.

In your case it might look like restic is starting from scratch as a full rescan needs to be done. But the 2nd part will basically start where it was left.

Note that this is a very basic overview of how restic works and parts of it might be technically incorrect. I just wanted to give you an idea of what’s going on.

See also

In your case it might look like restic is starting from scratch as a full rescan needs to be done. But the 2nd part will basically start where it was left.

Of course I understand the logic, but it’s strange, the full rescan was really looking like a new copy/backup of all files to the repository. I mean, as slow as a copy of files can be. Certainly because there wasn’t a parent snapshot yet. But I can’t verify now (or I’m not very motivated), I’ve just deleted the entire repository and I am about to rerun the commands.

And the PR is relevant indeed.
Thanks.

Really appreciate this tool with its forum.

If your initial backup is huge and you are afraid of (unintentionally) interrupting it you can split it up into smaller parts. As an example consider this directory structure:

/backuproot
  |-directory1
  |-directory2
  |-directory3

You can start by excluding the 1st and 2nd subdirectory:
restic backup --exclude directory1 --exclude directory2 /backuproot

Once that backup has completed you exclude only the 1st subdirectory:
restic backup --exclude directory1 /backuproot

Once that backup has completed you can backup the whole directory:
restic backup /backuproot

Using this method restic will automatically pick the right parent snapshot and subsequent backups will be sped up by a lot.

Thanks, the backup ended successfully this night.

Cheers