KenKundert / emborg

Interactive command line interface to Borg Backup
GNU General Public License v3.0
94 stars 8 forks source link

Potential issue with linked folders #46

Closed stratosgear closed 2 years ago

stratosgear commented 2 years ago

It seems that if I try to restore files from a linked folder I get an error.

A demonstration of the failure:

# First create the folder structures
root@yoda:/# cd /tmp
root@yoda:/tmp# mkdir -p folder/subfolder
root@yoda:/tmp# touch folder/subfolder/file.txt
root@yoda:/tmp# ln -s folder linked_folder

# Show the emborg configuration files
root@yoda:/tmp# cat ~/.config/emborg/plain_path
src_dirs = '/tmp/folder/subfolder'           # absolute path to directory to be backed up
root@yoda:/tmp# cat ~/.config/emborg/linked_path                                                                                                                                                                                           
src_dirs = '/tmp/linked_folder/subfolder'           # absolute path to directory to be backed up

# Create the two borg backups and show their manifests
root@yoda:/tmp# emborg -c plain_path create
root@yoda:/tmp# emborg -c linked_path create                                                                                                                                                                                               
root@yoda:/tmp# emborg -c plain_path manifest
Archive: yoda-2021-08-19T20:40:10
tmp/folder/subfolder
tmp/folder/subfolder/file.txt
root@yoda:/tmp# emborg -c linked_path manifest                                                                                                                                                                                             
Archive: yoda-2021-08-19T20:40:27
tmp/linked_folder/subfolder
tmp/linked_folder/subfolder/file.txt

# Perform restore on the original (unlinked) folder
root@yoda:/tmp# cd folder/subfolder
root@yoda:/tmp/folder/subfolder# ls -al
total 0
drwxr-xr-x  2 root root  60 Aug 19 20:39 .
drwxrwxrwt 14 root root 300 Aug 19 20:41 ..
-rw-r--r--  1 root root   0 Aug 19 20:39 file.txt
root@yoda:/tmp/folder/subfolder# mv file.txt file.txt.deleted
root@yoda:/tmp/folder/subfolder# emborg -c plain_path restore file.txt
Archive: yoda-2021-08-19T20:40:10
root@yoda:/tmp/folder/subfolder# ls -al
total 0
drwxr-xr-x  2 root root  80 Aug 19 20:42 .
drwxrwxrwt 14 root root 300 Aug 19 20:42 ..
-rw-r--r--  1 root root   0 Aug 19 20:39 file.txt
-rw-r--r--  1 root root   0 Aug 19 20:39 file.txt.deleted

# Try to perform the same on the symlinked folder
root@yoda:/tmp/folder# cd ../..
root@yoda:/tmp# cd linked_folder/subfolder
root@yoda:/tmp/linked_folder/subfolder# ls -al
total 0
drwxr-xr-x  2 root root  80 Aug 19 20:42 .
drwxrwxrwt 14 root root 300 Aug 19 20:42 ..
-rw-r--r--  1 root root   0 Aug 19 20:39 file.txt
-rw-r--r--  1 root root   0 Aug 19 20:39 file.txt.deleted
root@yoda:/tmp/linked_folder/subfolder# rm file.txt
root@yoda:/tmp/linked_folder/subfolder# emborg -c linked_path restore file.txt
Archive: yoda-2021-08-19T20:40:27
emborg error: borg extract: Include pattern 'tmp/folder/subfolder/file.txt' never matched.

It seems like emborg is trying to match the original path (the path that the symbolic link is pointing too) instead of the actual path.

Isn't this a bug on emborg?

Thanks, btw for an otherwise cool utility! :)

KenKundert commented 2 years ago

Thanks for pointing this out. That is a excellent bug report, and you found a pretty obscure bug. I have worked up a tentative fix for the problem. I am updating the tests now and should be able to upload the new version to github relatively soon.

KenKundert commented 2 years ago

I have update the repository on GitHub. If you like you can try it out and make sure it is working for you. I am still adding tests, so things still might change before it goes onto pypi.

stratosgear commented 2 years ago

I wouldn't mind testing it locally (I would not do that on my nas server yet).

It seems easy to make a local build with:

git clone https://github.com/KenKundert/emborg.git
$ pip install --user ./emborg

but my question is HOW would I be able to remove the development version (from my local laptop) if I ever want to run the final/official release? I do not want to be stuck with a dev version!

KenKundert commented 2 years ago

You can uninstall a previously installed package with

pip3 uninstall emborg

Or, you can simply install the new version; doing so automatically removes an earlier version and replaces it. No worries about testing. I have run your test case and am confident it works. I only suggested it in case you have other things you wanted to make sure worked before I release the new version.

stratosgear commented 2 years ago

Ok, just recreated the above example on my laptop, from your latest master,and I can say that the issue is now gone! The issue can be closed! Thanks!

KenKundert commented 2 years ago

The release that fixes this issue (1.25) has been pushed to pypi.