Backups can be created at remote server via ssh. Destination folder
should be given like “root@192.168.0.1:/bakcups”
NOTE: Assumed public/private key config is ok.
- Fixed bug on OS X since "--" is not supported by sed.
- Changed sed to grep for consistency with rest of the code.
- Splitted handling of rsync errors/warnings - for errors we quit with
an error code, for warnings we print a message but complete the backup
process.
- Removed old backup deletion prompt as it's not really needed.
- Made all variables uppercase for consistency.
- Used double square brackets in `if` statements.
Previously the date handling expiry logic had a bug where if you had
backups that were a year apart to the day, it wouldn't notice the
difference in year and only notice that the month was the same, and
expire the older one (eg, if you had a backup on 2012-04-01 and
another on 2013-04-01, it'd delete the one from 2012. This commit
makes it compare the full date string instead of just the month, so
that it more robustly keeps older backups.
Code was in the wrong place (link being added when the backup failed only).
Also made the symlink relative to the current folder so that the drive
can be mounted with a different path.
Code was assuming that you'd run backups hourly, eg, so you'd have
many backups within the last 24 hours. Code assumed that by the time
you found a backup more than 24h old, you'd already have a value for
$prev set. In the event that your most recent backup is more than 24
hours old, $prev would not be set and bash would get an error "unary
operator expected" when it tried to compare the day of the newest
backup to the empty $prev value.
I fix this by setting a default value for $prev, one that cannot be
mistaken for an existing backup because it does not represent a valid
date. This ensures that the most recent backup is correctly preserved
regardless of it's age.