How to Automate Backups on Linux with a Script

With an rsync script scheduled by cron, with no need for additional software.

Advanced 1 min read Published on 2026 By Equipo SolucionaPC

A simple script with rsync scheduled by cron covers most home needs, with no need for additional software.

The script

#!/bin/bash
DATE=$(date +%Y-%m-%d)
rsync -av --delete /home/your_user/Documents/ /media/external_disk/backup-documents/
echo "Backup completed: $DATE" >> /home/your_user/backup.log

Save it as backup.sh, give it execute permissions:

chmod +x backup.sh

--delete removes files from the destination that no longer exist at the source, keeping an exact mirror copy. Remove it if you'd rather the destination only accumulates, never deleting anything.

Scheduling it with cron

crontab -e

Add this line to run it every day at 2 AM:

0 2 * * * /full/path/backup.sh

Tip: test the script manually first (./backup.sh) before scheduling it — confirm it works as expected before leaving it running unattended.

Frequently asked questions

What exactly does rsync do that a normal copy doesn't?

It only copies what has changed since last time, instead of copying everything again — much faster on repeated backups of large amounts of files.

Is it safe to use --delete in the script?

It keeps an exact mirror copy of the source, but means that if you delete something by mistake at the source, it also gets deleted at the destination on the next run. Remove it if you'd rather the destination only accumulate without ever deleting.

Share: