Hi @Sina
If I understand your question correctly, I think I recently went through a similar process.
I moved to restic from a backup system based on rsnapshot (rsync + hardlinks). ext4-formatted rather than your NTFS, but I don’t think that matters.
I wanted to move the original repository from a usb HDD into restic as cleanly as possible. The objective was to:
- Maintain the same “snapshot” structure
- Tag snapshots as being from the old system
- Store the original snapshot creation times
- Maintain the same paths between snapshots.
While (4) was unnecessary (restic deduping would work, irrespective of path), it made browsing old snapshots a bit more elegant.
Once mounted, my old repository was at the path /media/veracrypt2/ext4_4tb/backup/. This directory then contained multiple snapshots, each within their own directories (daily.0, daily.1 etc.).
To keep it simple, here’s a tidied-up version of the BASH script which achieved only (1-3) above. Hopefully I didn’t break anything during the tidying, and apologies for my mediocre BASH abilities:
export RESTIC_REPOSITORY=<path_to_new_repo>
export RESTIC_PASSWORD=<password>
export RESTIC=./restic_0.9.5_linux_arm
RESTIC_TAG=rsnapshot
SOURCE_ROOT=/media/veracrypt2/ext4_4tb/backup/
for RESTIC_SOURCE in $SOURCE_ROOT/*/; do
RESTIC_TIME=`date "+%Y-%m-%d %H:%M:%S" -r $RESTIC_SOURCE`
echo $RESTIC_SOURCE "$RESTIC_TIME"
time $RESTIC backup --tag $RESTIC_TAG --time "$RESTIC_TIME" "$RESTIC_SOURCE"
done
In order to achieve (4), I made a symbolic link to each snapshot directory before each restic run. I’m guessing there might be a cleaner solution, but I’m a newbie, and it got the job done. Since the symlink was in a root-owned directory I also had to sudo a few of the commands (an unnecessary complication for here). Here’s the additional variable needed for my case, along with the updated for loop:
RESTIC_SYMLINK_PATH=/mnt/rsnapshot
for RESTIC_SOURCE in $SOURCE_ROOT/*/; do
RESTIC_TIME=`date "+%Y-%m-%d %H:%M:%S" -r $RESTIC_SOURCE`
echo $RESTIC_SOURCE "$RESTIC_TIME"
#make the symbolic link, and point the restic command here
sudo rm "$RESTIC_SYMLINK_PATH"
sudo ln -s $RESTIC_SOURCE "$RESTIC_SYMLINK_PATH"
time $RESTIC backup --tag $RESTIC_TAG --time "$RESTIC_TIME" "$RESTIC_SYMLINK_PATH"
done
This process obviously took quite a while to run, and I was forced to stop it halfway through for other reasons. A hackish way to resume was just to enclose the restic command in an if statement and manually exclude a list of already-completed snapshots.
Hope that’s of some help.
First-time-posting happy restic newbie: nice work guys - your tool is great!