Is it better to do one big backup with all services or one backup per service

Hello, I am trying to setup my server’s backup script but I have a dilemma. Some services require to be shut down before backup. So I have two options:

  • Option 1: For each service: I shut it down, backup, and start it again
    • Pros: Shorter downtime, since it only needs to wait for that one service to backup
    • Cons: I don’t know how Restic’s compression system works, but I’m guessing it might overall take more space as all the services aren’t backed up together?
  • Option 2: I shut down all the services. Back everything up. Then start everything again.
    • Pros: No more worry about Restic’s compression since everything will be backed up in one go.
    • Cons: Longer downtime, since in order for each service to be restarted, it needs to wait for all the other services to be backed up.

So in other words, does doing several restic commands such as:

restic -r <my repo> backup /path/to/backup1
restic -r <my repo> backup /path/to/backup2

Have a negative impact on the overall disk space used on the repository compared to this:

restic -r <my repo> backup /path/to/backup1 /path/to/backup2

And if so, how big is that impact? Or would you have other ideas to solve this problem?

The best option is not to backup live filesystem. Stop your services, take filesystem snapshots, start services. Then run restic against your snapshots. Does not matter how long it takes

All modern operating systems support it.

here more details and some examples:

Hmm that’s interesting but wouldn’t doing this require a lot more available storage to keep the filesystem snapshot? In my case I really don’t have much space.

Also if the services needs to be stopped anyway, what’s the benefit of the snapshot? There’s no risk of data being written during the backup since everything is stopped.

Taking snapshot is instant. Well.. lets say few seconds. This is then downtime of your services. After running backup you can delete snapshots.

Frankly it is the only proper way to do what you want. Everything else is just poor workaround IMO.

1 Like

Hmm I’ll see. The thing is my server is on an ext4 filesystem which doesn’t support snapshots it seems too.

It does. Just not directly. Google lvm snapshots.

1 Like

Also re limited space. Snapshots initially take no space at all.

2 Likes

Apart from the snapshot topic, there is no significant difference between the two Restic backup commands or between backing up both directories at once. Deduplication and compression take place in both cases. There will be a little more overhead in the first case because there will be two snapshots, whereas in the latter there will only be one, but the amount of space that your data allocates on the backup medium will be the same.

2 Likes

What services are you backing up? Are any services dependent on others, such as a web server on a database server? Some might be ok being backed up while running. One technique I use for databases is I run an export of the database and I back that up, rather than backing up the database itself.

What colorimeter said about space / compression is how I understand things too.