laurent22 / rsync-time-backup

Time Machine style backup with rsync.
3.38k stars 446 forks source link

rsync: failed to open exclude file #182

Closed lyenliang closed 4 years ago

lyenliang commented 4 years ago

I tried to run rsync_tmbackup.sh with --exclude-from option. But it always gives me rsync: failed to open exclude file --exclude-from=exclude_list.txt: No such file or directory (2) error

Here's my folder structure:

.
|-- exclude_list.txt
|-- README.md
|-- rsync_tmbackup.sh
`-- tests
    `-- populate_dest.php

Here are the things I've tried:

  1. Add full path --exclude-from=/home/ec2-user/rsync-time-backup/exclude_list.txt to the end of the command.

    ./rsync_tmbackup.sh -i ~/.ssh/my-key.pem -p 22 /home/ec2-user/rsync_folder ec2-user@123.123.123.123:/home/ec2-user --exclude-from=/home/ec2-user/rsync-time-backup/exclude_list.txt
  2. Add relative path --exclude-from=exclude_list.txt to the end of the command, and put exclude_list.txt to the folder where rsync_tmbackup.sh is located in.

    ./rsync_tmbackup.sh -i ~/.ssh/my-key.pem -p 22 /home/ec2-user/rsync_folder ec2-user@123.123.123.123:/home/ec2-user --exclude-from=exclude_list.txt

Anyone knows how to use --exclude-from?

kapitainsky commented 4 years ago

As per manual:) Usage: $(basename $0) [OPTION]... <[USER@HOST:]SOURCE> <[USER@HOST:]DESTINATION> [exclude-pattern-file]

so in your case run

./rsync_tmbackup.sh -i ~/.ssh/my-key.pem -p 22 /home/ec2-user/rsync_folder ec2-user@123.123.123.123:/home/ec2-user /home/ec2-user/rsync-time-backup/exclude_list.txt

lyenliang commented 4 years ago

@kapitainsky Thank you. Now it works.

kapitainsky commented 4 years ago

if you would like directly specify rsync --exclude-from or any other rsync parameter you have to use --rsync-set-flags e.g.

./rsync_tmbackup.sh --rsync-set-flags="--exclude-from=exclude_list.txt" -i ~/.ssh/my-key.pem -p 22 /home/ec2-user/rsync_folder ec2-user@123.123.123.123:/home/ec2-user