1

I am working on a backup script but got some problems with my script, can you help me?

INCLUDE="/data/scripts/include.txt"
EXCLUDE="/data/scripts/exclude.txt"
DST="/backupdir"

    rsync \
      --archive \
      --recursive \
      --include-from $INCLUDE \
      --exclude-from $EXCLUDE \
      --hard-links \
      --perms \
      --executability \
      --owner \
      --group \
      --human-readable \
      --verbose \
      --progress \
      --delete-before \
      --stats \
      --timeout=300 \
      -e "ssh -i $SSHKEY" $USER@$IP:$DST
#include
/root
/data
/etc/httpd
/data/lost+found
#exclude
/data/www/html/nextcloud/public_html/data/index.html
/data/www/html/nextcloud/public_html/data/nextcloud.log
/data/www/html/nextcloud/public_html/data/updater.log
/data/www/html/nextcloud/public_html/data/updater-*

My question is, how do I tell rsync to rsync everything thats in the include-file , exclude everything thats in the exclude-file without giving him a source path?

1

The manual says you have to have a source directory.

You should use the list in your include file as a list of source directories to loop through and rsync from:

for dir in /root /data /etc/httpd
do
    rsync OPTIONS $dir DEST
done

Or, you can make / your source directory, and have something like /* in your exclude pattern.

  • Thank you very much! – xDuckyDuc Jul 10 '19 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.