Restic files in a separate path?

Hi there,
I’m trying to backup my home directory without it being filled with restic folders.

I ran (in the home directory):
restic init --repo .

Then I ran
restic backup . .... (with the relevant settings).

The backup is working, my issue is that restic is creating many folders (locks, keys, index, snapshots, data).

Is there a way to have these folders stored somewhere else while still backing up the home directory?

Welcome to the forum @azdev.

Why don’t you make a folder in your home directory named e.g. backup and init your repository in there instead of directly in your home? That should make it all cleaner.

But in general I’m wondering why you keep your repository in the same place that you back up. You gain very little by doing that, it would be better if you store your repository somewhere else (on another host, preferrably off-site).

It’s unclear to me what problem you’re trying to solve in the way you’re currently doing things.

Hi @azdev and welcome to the forums!

Just to add to what @rawtaz said, you can have the pretty much anywhere you have write-access to.
When you want to use a different directory, change the --repo . argument to --repo /path/to/repository (Substituting /path/to/repository with the location you want the repository at. ) The --repo argument tells restic where the repository is located. You’ll need to run restic init --repo .... again there though.

As @rawtaz mentioned, generally you shouldn’t have the repository in the same location you’re backing up. This is generally not beneficial, but I’d imagine could also be harmful if restic tries to backup it’s own repository into itself. The reason restic did it in your home directory was because your terminal session working directory was your home directory and you ran restic --repo . init. You may know already, but in Linux/Unix, . is shorthand for the current working directory. Generally this isn’t a great practice for something like restic either, as full paths are your best bet for making things always work. If you were in another directory, restic would try to backup to the directory you were in, where there’s no repository. The same thing goes for the directory to backup in restic --repo ... backup /backup/here. Something better would likely be: restic backup --repo /restic/repository/path backup ~/ (replacing the repo path again.)

I apologize if this information is already familiar to you, but I just wanted to clarify just in case.

Good luck,

Alternatively, they can move all of the restic directories and files to the new location.

mv config data index keys locks snapshots /path/to/new/repository/location
1 Like