Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I prevent a directory from being removed in rsync
    primarykey
    data
    text
    <p>I am trying to make a script for backing up my home and other important directories to an external drive, while excluding certain directories and filetypes (<code>--exclude</code>). Excluded files need to be deleted on the backup as well, in case I add a filetype or directory to the exclude list (<code>--delete-excluded</code>).</p> <p>Also, everything that is removed needs to be backed up as well, in case something goes horribly wrong (<code>--backup --backup-dir=rsync/backup</code>). </p> <p>I am starting out with this:</p> <pre><code>#!/usr/bin/env bash PATH_PWD="`pwd`" PATH_HOME=~ SRC="/home/redsandro" PATH_TARGET="/media/redsandro/MyBook 4TB/backup/`hostname`" PATH_BIN="${SRC}/bin" EXCL_FROM="${PATH_BIN}/rs-backup-external.sh.exclude.txt" DATE="`date +%Y-%m-%d`" OPTS="-ahl --update --del --delete-excluded --force --ignore-errors --progress --stats --exclude-from=$EXCL_FROM --log-file=~/rsync/rsync.$DATE.log" OPTS="$OPTS --backup --backup-dir=rsync/backup/${DATE}" #OPTS="$OPTS --dry-run" echo Backing up $SRC to $PATH_TARGET... echo sudo rsync $OPTS "$SRC/" "${PATH_TARGET}${SRC}" </code></pre> <p>Now, obviously, <code>--del</code> conflicts with <code>--backup --backup-dir=rsync/backup</code>. Can I exclude this directory from being deleted? Or is there perhaps an easier way to do this?</p> <p>My goal is to have a script that I can run on all my machines, where a part syncs to a computer-specific directory, and another part (documents, pictures) sync to a global directory because they all need to be the same anyway.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload