Restoring on a new host


#1

Hi there and apologies for the noob question .
I would like to backup from one host and restore a snapshot on a new host . When I try to list snapshots on the new machine ( the one to restore to ), the snapshot list comes up empty, whereas my original hosts can list the snaphosts fine . I use the same restic password for both hosts, so I think I’m not getting the idea about the keys/password usage .

Would anybody be able to tell me host to backup from host1 and restore onto a new host2 ?

thank you :slight_smile:


#2

This would indicate that you are not using the same repository for both machines, or you are using the --host option incorrectly.

Please post the command you’re running on both machines, as well as the output.


#3

sure thing , here are my bash scripts:

Host1 (ubuntu)

#!/bin/bash
export RESTIC_REPOSITORY='s3:https://s3.us-west-1.wasabisys.com/myrepo'
export AWS_ACCESS_KEY_ID=myaccessid
export AWS_SECRET_ACCESS_KEY=mysecretaccesskey
export RESTIC_PASSWORD=myresticpassword
restic -r s3:https://s3.us-west-1.wasabisys.com/myrepo init
restic -r s3:https://s3.us-west-1.wasabisys.com/myrepo backup /media/Photos/2017/2017-01-01/  --exclude .AppleDouble
restic -r s3:https://s3.us-west-1.wasabisys.com/myrepo snapshots

output

created restic repository 193a030f3f at s3:https://s3.us-west-1.wasabisys.com/myrepo

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
password is correct
scan [/media/Photos/2017/2017-01-01]
scanned 1 directories, 8 files in 0:00
[0:25] 100.00%  46.418 MiB / 46.418 MiB  9 / 9 items  0 errors  ETA 0:00
duration: 0:25
snapshot bb5bfea9 saved
password is correct
ID        Date                 Host        Tags        Directory
----------------------------------------------------------------------
bb5bfea9  2018-11-24 14:50:20  jupiter                 /media/Photos/2017/2017-01-01
----------------------------------------------------------------------
1 snapshots

Host 2 (Raspbian)

#!/bin/bash
export RESTIC_REPOSITORY='s3:https://s3.us-west-1.wasabisys.com/myrepo'
export AWS_ACCESS_KEY_ID=myaccesskey 
export AWS_SECRET_ACCESS_KEY=mysecretaccesskey
export RESTIC_PASSWORD=myresticpassword

restic  -r s3:https://s3.us-west-1.wasabisys.com/myrepo init
restic  -r s3:https://s3.us-west-1.wasabisys.com/myrepo snapshots

output

created restic backend c24b8999f0 at s3:https://s3.us-west-1.wasabisys.com/myrepo

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
ID        Date                 Host        Tags        Directory
----------------------------------------------------------------------

#4

Your mistake was to run init on the second host. init is for creating a repository. What you have effectively done is created two different master keys in the same repository which, to my knowledge, is unsupported. Because the master keys differ, neither host would be able to decrypt objects added by the other host.

In fact, I didn’t think it was even possible to run init twice! When I run restic init against an existing repository, I get:

Fatal: create repository at xxx failed: config file already exists

Assuming that this somehow did happen (what version of restic are you using!?) then a restic check on either host should complain bitterly.

Your best option here is to figure out which key was created by the second system and delete it. Then, use the password from the first computer on the second, and do not run init against the repository ever again.

Edit: I would guess that you are using two different versions, based on this difference in output:

created restic repository 193a030f3f at s3:https://s3.us-west-1.wasabisys.com/myrepo
created restic backend c24b8999f0 at s3:https://s3.us-west-1.wasabisys.com/myrepo

Note the different text (repository vs backend). Let us know the version on each system. If possible, make the versions match. Restic tries to be backwards compatible, but the binaries are statically linked and so there is very little reason to be running different versions. I suspect the version running on host 2 is old enough that init doesn’t check to see if a repository already exists.


#5

You were right on the money, the host1 was using v0.8.8 and the host2 was using an old 0.3.3 , I guess that’s what is currently in the raspbian repos .
I’ve upgraded both to 0.9.3 and got rid of the init on the host2 and bam, working . I guess I didn’t understand what init really did .

Thanks a lot !


#6

Hm, that should not be possible, indeed. There are a few checks in place to prevent that, besides the one you saw, e.g.:

Good catch, I missed that!

That’s entirely possible, thanks for digging in!