1

I have installed a fresh version of Debian. I would like to restore some files in home with my backuped version as well as some under etc. The backup was created with rsnapshot.

The point which is not that clear to me is as which user should I run the restore command. Let me make an example. Assume I would like to restore my rsnapshotfile within /etc/cron.d/. By default I see the following right permission in the fresh installed version:

station:~$ ls -l /etc/cron.d/rsnapshot 
-rw-r--r-- 1 root root 472 Mar 26  2016 /etc/cron.d/rsnapshot

In this case I need to run the rsync command as root or sudo, i.e. I was doing for testing:

@thinkstation:~$ rsync /media/3985DAA24356D774/rsnapshot/station/daily.0/etc/etc/cron.d/rsnapshot /etc/cron.d/rTest

But this leads to the following permissions:

station:~$ ls -l /etc/cron.d/rTest 
-rwxr-xr-x 1 root root 513 Sep 24 19:01 /etc/cron.d/rTest

and this doesn't match the system defaults one.

Another example, which is more frustrating. I was running rsync command as normal user (non root, non sudo). The files I've restored was a project which is version controlled via git. I did the restore because not all files were on github. After the restore I've seen a lot of difference because of the changed permission (which I don't understand as the files didn't involve any sudo rights and were transferred to my home directory). So I'm not sure if I did a mistake in the past while doing the backup or if I'm doing something wrong in restoring the files. In any case I would like to know how I can resolve that issue.

3
  • 1
    Please include the permission errors you got. Sep 23, 2017 at 15:34
  • @FaheemMitha I've updated my post. I think I was not very clear at the beginning. I'm sorry for that. Let me know if there is still something missing. cheers
    – math
    Sep 24, 2017 at 17:12
  • Hi. I haven't really taken the time to understand your issue, but consider other kinds of backup. I've been using Borg backup recently. It's a modern deduplicating backup. Check it out. Sep 24, 2017 at 21:10

1 Answer 1

2

You need to tell rsync you want to restore permissions. Judging from man 1 rsync I would propose the following options for restoring a single file:

-p, --perms                 preserve permissions
-t, --times                 preserve modification times
-o, --owner                 preserve owner (super-user only)
-g, --group                 preserve group

The -a often proposed to restore things from rsync based backups includes more options you don't need for a single file. So your command would look like follows:

rsync -ptog /media/3985DAA24356D774/rsnapshot/station/daily.0/etc/etc/cron.d/rsnapshot /etc/cron.d/rTest

Or with long options:

rsync --perms --times --owner --group /media/3985DAA24356D774/rsnapshot/station/daily.0/etc/etc/cron.d/rsnapshot /etc/cron.d/rTest

Because you specify --owner and --group this should work for both of your usecases.

If you want to restore a directory recursively, not only a single file, you might find this -a option useful, perhaps in combination with -v, which tells you what was copied:

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
-v, --verbose               increase verbosity

You must log in to answer this question.

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