I'm learning Bash and wrote a script to back up files to an external drive. It uses rsync and --link-dest to make daily snapshots with hard links for unchanged files.
What should I look at before trusting it with my backups?
I'm learning Bash and wrote a script to back up files to an external drive. It uses rsync and --link-dest to make daily snapshots with hard links for unchanged files.
What should I look at before trusting it with my backups?
Try restoring files before you rely on it. Check a few snapshots, including an older version of a file that changed, and make sure the restored files are usable. A backup that completes without an error is not quite the same thing as a tested restore.
Also test what happens if the external drive isn't mounted or a backup gets interrupted. You don't want a failed run to look like a good snapshot.
I'd break the script into functions and have a main function call them. It makes the steps easier to follow and gives you smaller pieces to check when something goes wrong. You can still keep it all in one file.
Have a look at rsnapshot for comparison. It uses the same general rsync and hard-link snapshot idea, so its approach could be useful even if the goal is to write your own script and learn from it.
Keep the hard-link behavior in mind when working with snapshots. Unchanged files can share the same underlying data, so modifying one in place can affect another snapshot too. Treat completed snapshots as read-only and test that changed files get separate copies.
Answers are reviewed before publication.
lemon-zest-later:
Building it is part of the learning goal, but comparing it with an existing tool sounds useful.