3

Apparently BackInTime, which uses rsync, doesn't just restore permissions when restoring files but also saves them separately to the data. Is it possible to restore permissions of specific directories / files only? I don't want to restore any files but only restore the permissions files had earlier.

Is this possible somehow?
If not the best way would probably creating a list changes of permissions by comparing files to the backup and doing it manually (related question).

I'm using Debian 9.1 with KDE.

2 Answers 2

6

GNU chmod can take a reference file:

--reference=RFILE
use RFILE's mode instead of MODE values

If the folder structure of your back remains the same, you could do something like:

cd /path/to/backup
find . -exec chmod --reference={} --changes /source/of/{} \;

/source/of is the path from which the backup was done.

Now you can use find's tests to only operate on the desired files/directories.

Since you say it uses rsync, I think the directory structure should be retained, and it should be possible for you to mount the remote system locally using SSHFS, etc., so in principle this should work.

3

We can get the list of files with the changed permissions by rsync -ani

rsync -ani newFile new/ | awk {'print $2'}

then we can pass the output to chmod and use the output for reference file from backup to original file where the permissions have been changed:

rsync -ani newFile new/ | awk {'print $2'} | xargs -I@ chmod --reference=new/@ @

I tried to reproduce the instance by creating a file and did rsync to new directory, then changed the permissions of original file:

[pijain@kuliza370 testing]$ ll
total 0
drwxrwxr-x. 2 pijain pijain 21 Aug 29 16:56 new
-rwxrwxrwx. 1 pijain pijain  0 Aug 29 16:56 newFile(origial file with 777)
[pijain@kuliza370 testing]$ ll new
total 0
-rw-rw-r--. 1 pijain pijain 0 Aug 29 16:56 newFile(backup with 644)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .