Chapter 5. Automated administration: Configuring automated offsite backups

 

This chapter covers

  • Automating administrative tasks with scripts
  • Increasing security and system efficiency
  • Backing up local data
  • Scheduling automated tasks

If there’s one thing that I’d hope I made sufficiently clear in the previous chapter, it’s that regular and reliable system backups are absolutely critical. But, in many ways, the hard part is the regular. Keeping up with important tasks with immediate consequences is hard enough; remembering to run some dull daily or weekly backup is pretty much a nonstarter.

It’s no secret: the single best solution to the problem is to configure an automated scheduler to perform the task for you and then forget about it. Until recently, the scheduler you’d use on Linux would almost certainly have been some variation of the software utility cron; and, in fact, that’s still a great choice. But the systemd process manager you learned about back in chapter 3 has added systemd timers into the mix.

I’m going to cover both approaches in this chapter, but I’ll also show you how to package backups and any other administration task into scripts, which can themselves be put on an automated schedule. To demonstrate how it all works in the real world, I’ll craft a command to backup some data to an AWS Simple Storage Solution (S3) bucket and then use the command to create schedulers using both cron and systemd timers.

5.1. Scripting with Bash

5.2. Backing up data to AWS S3

5.3. Scheduling regular backups with cron

5.4. Scheduling irregular backups with anacron

5.5. Scheduling regular backups with systemd timers

Summary

Key terms

Security best practices

Command-line review

Test yourself