Repository lost after formatting other hard drive

Hi,

I run into the problem that my repository was gone from my hard drive after formatting a different one.

I’m using Linux Mint and wanted to do a re-installation of the system.
My PC has two hard drives. The first is used for the operating system and the data. The 2nd is intended for backups and until now I only run timeshift which is a program that comes with Mint and does system snapshots but without data.
So I did download restic and created a new repository on the backup drive where I wanted to backup data from my home directory.

I belive (can’t remember exactly) the commands I used where the following:
restic init --repo /media/akis/drivexyz/restic-repo
restic -r /media/akis/drivexyz/restic-repo --verbose backup ~/Pictures ~/Documents

Afterwards I found the restic repository under /media/akis/drivexyz/ besides the files from timeshift.

Keen that my files are backed up safely I did format the hard drive and re-installed the os.
After booting I cannot find the restic repository on the other drive anymore while the timeshift files are still in place.

It is not an ultimate problem as I had another backup on an external drive I did manually and I’m currently restoring from. But I want to understand what I did wrong.

Thanks in advance.

The /media directory is a subdirectory of the root OS filesystem and is on the same drive / partition as your Mint OS. So when you deleted your OS, you deleted the /media dir and all of its contents along with it.

Under Ubuntu-based Oses, the /media directory is intended to be used as a location for mounting temporary removable devices, eg a USB SSD or a pen-drive; it’s not really a suitable location for storing your restic repo.

A guide to Linux directory structures: Learn Basics of Ubuntu directory structure

hth

OK that sounds logic but why haven’t I lost the files from timeshift as well then?
I just checked and these are no new files created upon first OS start but from last year.

OK that sounds logic but why haven’t I lost the files from timeshift as well then?

Without knowing more details of how you have set up Timeshift, we can only speculate.

My guess: your Timeshift ddata was mounted to the /media folder, and the data was saved to your other drive as you believed it was.
Whereas you created the restic repo directly in the /mount folder, rather than via the mount point in /media, which means the restic repo was actually on your OS drive, and not the other one.

But i’m just speculating at this point.

Unfortunately I cannot reconstruct it.

Must have done something like that.

Thanks for your answers, the link and the educated guess. I’ll be more careful next time.

For reassurance, mount your 2nd HDD to a suitable mountpoint in your new OS and create another restic repo and backup a test dir(s) to it.

Check you can see the restic repo & its subdirs by ls’ing the mountpoint.

Now unmount the mountpoint; ls on the mountpoint should now show an empty dir.

FInally, mount the the repo again and check it’s back.

Apologies if all this is obvious.

1 Like

Another recommendation is to use a live system and try to access your backup from there. That will show whether your backup actually works as intended.

1 Like

I use linux for a while now but still having troubles understanding the file system. So I’m thankful for any advice.

I did as told except for the suitable mountpoint part. For some reason my system mounts the 2nd HDD to /media/akis instead of /dev upon startup.
Don’t know why. Checked fstab but it’s not listed. Anyways here’s what I did:

created new snapshot

sudo restic -r /media/akis/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb/restic-repo/ --verbose backup ~/testdir1/ ~/tesdir2/
open repository
enter password for repository:
repository 103afe49 opened successfully, password is correct
created new cache in /root/.cache/restic
lock repository
load index files
no parent snapshot found, will read all files
start scan on [/home/akis/testdir1/ /home/akis/tesdir2/]
start backup on [/home/akis/testdir1/ /home/akis/tesdir2/]
scan finished in 0.238s: 2 files, 242.529 KiB

Files: 2 new, 0 changed, 0 unmodified
Dirs: 4 new, 0 changed, 0 unmodified
Data Blobs: 2 new
Tree Blobs: 5 new
Added to the repo: 244.755 KiB

processed 2 files, 242.529 KiB in 0:00
snapshot ba66c379 saved

ls command to see if repo and subdirs are present

sudo ls /media/akis/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb/restic-repo/
config data index keys locks snapshots

unmount HDD

umount /media/akis/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb

ls command to see if repo and subdirs are present

sudo ls /media/akis/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb/restic-repo/
ls: Zugriff auf ‘/media/akis/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb/restic-repo/’ nicht möglich: Datei oder Verzeichnis nicht gefunden

→ couldn’t find the directory

mounted again and
sudo ls /media/akis/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb/restic-repo/
config data index keys locks snapshots

I also did what @MichaelEischer recommended with the live system and was able to restore the test directories there.

At this point I’m quite sure that your first guess was correct and I created the repository that I lost under /media/akis instead of /media/akis/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb.
I don’t remember using such a long line of characters.

Thanks again for the help!

1 Like

Small addition at the end for finding your way though the drives:

mount shows all the drives that are mounted but it’s somewhat convoluted nowadays so I tend to use df -h more often (disk free info) or even lsblk -f (list block devices). The latter also shows you the UUIDs of the drives. That’s the “long line of characters” you mentioned. It is unique per drive and can be used to identify and correctly mount specific block devices to specific folders, for instance like so:

mount /dev/disk/by-uuid/8c5b134c-d2b3-46d5-88d7-7a0f6c7103fb /backup

/etc/fstab uses UUIDs as well to mount important drives at boot time.

1 Like