Backing up LXC containers

Is it safe to backup running LXC containers directly from the host using restic or should I install restic inside each container and then do backups? I mean containers running services like nginx, prosody. Databases will be backed up using SQL dumps

When possible, running a backup agent inside of your instances is preferred as the agent can then do things like pausing services or asking databases to flush their writes, something that’s not really feasible when running from the outside.

1 Like

Is it safe to run backup agent outside the containers if I don’t run any tasks inside containers such as restarting services or asking databases to flush their writes?

Without cooperation from what’s running inside of the instance, you may get inconsistent backups which then may or may not function when restored and may then need additional work post-restoration to get things back online.

ChatGPT told that I should first stop containers, then do backup of them and then start them again. Do I correctly understand that it’s unnecessary step? Instead of it, it’s sufficient to let do backup agent do its job inside containers, right?

It depends if you want a guaranteed consistent state or not.
If you do, you either need a backup agent in the container or you need to stop them.
If you don’t, you can do a backup from outside the container while it’s running and hope that your backup will be restorable.

1 Like

Thank you for complete explanation.