* 2021-02-18 11:13:25-0500, Gary Dale wrote:

> rsync is a quick & dirty backup tactic but it's got limitations.
>
> 1) files may stay around forever in the backup even if you've deleted 
> them from your main computer because you don't need them.
>
> 2) you only have one copy of a file and that only lasts until the next 
> rsync. This limits your ability to restore from a backup before it is 
> overwritten.

> rsync is not a good substitute for backups.

Rsync is great backup program with "--link-dest" option. Here is the
idea in simplified code:

    cd "$destination"
    new=$(date +%Y%m%dT%H%M%S%z)
    if mkdir "$new" && \
        rsync -aHAX --link-dest=latest_backup [...] \
        "$source" "$new"
    then
        # Recreate symlink to point to the new backup directory.
        ln -sfn "$new" latest_backup
        # Delete old backups.
        find . -mindepth 1 -maxdepth 1 -type d -mtime +365 \
            -exec /bin/rm -fr -- {} +
    fi

With that sort of code every backup is a new complete directory tree in
a time stamped directory. If files have not changed since the latest
backup "--link-dest" creates hard links. Old backups can be deleted by
removing old (or any) directory tree. The trees don't depend on each
other.

What else do we need? OK, some people may need compression but usually
hard disk space is cheap.

-- 
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450

Attachment: signature.asc
Description: PGP signature

Reply via email to