3

I run my rsync backups without the --delete flag just in case something is deleted accidentally. In my logs with the -v flag I simply get informed of a change in the parent directory of the deleted file, so I cannot tell what file was affected. When I use the -vvv flag, I get no descriptive information that separates the deleted file from the rest of the files. Same when including --itemize-changes.

I am trying to find a way to get updated in my logs when a file was deleted on my host machine even though I do not want it deleted on my target machine. I want to be able to check what was deleted every so often before running the --delete flag manually. I want to run the rsync log info through a simple script to make a list of 'deleted' files (files deleted only on machine a but not machine b), but cannot find the information that basically says "a file was deleted on machine a but not making any changes to the backup on machine b.

My commands:

rsync -avz -e ssh /files/to/backup [email protected]:/Target/backup/file --log-file=/path/to/log -q

or

rsync -avvvz -e ssh /files/to/backup [email protected]:/Target/backup/file --log-file=/path/to/log -q

1 Answer 1

4

Use --delete together with --dry-run in your command.

From man rsync:

--delete

    This option can be dangerous if used incorrectly! It is a very good idea to
    first try a run using the --dry-run option (-n) to see what files are going
    to be deleted.
5
  • That's an interesting idea, but to use that (in anacrontab), I would have to run rsync twice right? Once to get deleted files and once for the actual backup as I don't see how I can dry run and normal run at the same time.
    – i9pp0
    Nov 27, 2020 at 12:01
  • Your question states:but not making any changes to the backup on machine b You can do that only with --dry-run. That's what you asked for. If you want to make changes in destination afterwards, off course you have to run the command again without--dry-run.
    – mook765
    Nov 27, 2020 at 12:20
  • Yes, maybe I didn't clarify correctly. I would like to run a command that does my backup and returns files deleted on 'a' but not on 'b'. As is now, the output to stdout is simply that the directory that contains the deleted file has changed. I would like more detailed info on that change, more specifically the name of the file 'deleted'. Is that possible with rsync?
    – i9pp0
    Nov 27, 2020 at 12:26
  • What is the problem with running two commands? Just put both commands in a single script and call the script with cron.
    – mook765
    Nov 27, 2020 at 12:38
  • Yes, I was just curious if there was another way. Actually when I want to run a delete, I can just a run a dry run first and there's my list of files to be deleted for checking. Good answer. I think I over thought things :)
    – i9pp0
    Nov 27, 2020 at 13:38

You must log in to answer this question.

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