Guides Laptop Backups With anacron

Laptop Backups With anacron

cron is great for servers and desktops that are always on, but if
you want to schedule a backup (or indeed any other job) on a laptop or other
machine that may not always be on, try anacron

Not every scheduled task can take place on an always-on machine. For those we have anacron. With anacron, like cron, you schedule a job to run at specific
intervals. Unlike cron, when the computer is switched on the anacron daemon checks whether a task should have run and if one was, it runs it.

With cron, you schedule a job at a specific date and time. If at that particular time the machine is down, the job just won’t run (until the next
time it’s scheduled). With anacron, you schedule a job to run at specific
intervals, for example, daily, weekly or monthly. anacron will try to keep as
closely to this schedule as system uptime permits. If a job is supposed to
run daily, but when the computer is switched on the anacron daemon finds that
it hasn’t run in the last 24 hours, it will be run there and then.

The main downside of anacron is that you can run it only at
intervals of one or more days. cron, on the other hand, can be run at intervals
as small as one minute. For most backup schedules, this won’t be a problem.

A further issue is that anacron can be configured only by the root
user, whereas cron can be used by anyone. Again, this is
unlikely to be a problem for laptop backup.

To set up an rsync backup for your laptop, edit the file

/etc/anacrontab, as root, and add the following single line:

1 5 backup rsync -auz -e "ssh -i /home/user/.ssh/rsync" /test

This line will run the given rsync command every day (the first parameter)
with a delay of five minutes (the second parameter) and identify the job in
logs as ‘backup’ (the third parameter). As with cron, anything after
the time and log parameters is assumed to be part of the command to be

This tip is taken from my current book, Linux System Administration Recipes. Check it out for more sysadmin hints and tips.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of “Linux System Administration Recipes: A Problem-Solution Approach” (Apress, 2009).

Follow ServerWatch on Twitter

Latest Posts

KVM vs VMware Hypervisor Comparison 2020

The KVM vs VMware hypervisor comparison is a classic debate. Hypervisors have increased in usability and power over the last several years as more...

Compare HP’s iLo & Dell’s iDRAC Server Management Tools

Most servers shipped from the major manufacturers today come with some type of out-of-band management tool or baseboard management controller (BMC). Two of the...

Get-MsolUser PowerShell Attributes & Properties

This article has been updated for 2020. Please note that WAAD was retired in 2018, but the cmdlets listed in this article are still...

Microsoft Azure PowerShell Scripts and Commands

Using PowerShell scripts and commands for quickly executing tasks in Windows operating systems offers a number of benefits over traditional scripting languages, such as...

Microsoft Hyper V Review

Microsoft Hyper-V: The Bottom line Microsoft Hyper-V lagged behind VMware's virtualization tool, one of the most popular tools in the space, when it was first...

Related Stories