The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 5,424β€…    Votes:  3β€…
Tags: backup   cron  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

Title: Simple Backup Solution
ID: /2018/04/29/Simple-Backup-Solution
Created: April 29, 2018
Upload: September 20, 2023    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false

Here is part of a solution from my daily backup script which is called by cron: Backup Linux configuration, scripts and documents to Gmail. The full script is in appropriate because:

Here is the relevant script, parts of the which you might adapt:

# NAME: daily-backup
# DESC: A .tar backup file is created, emailed and removed.
# DATE: Nov 25, 2017.
# CALL: WSL or Ubuntu calls from /etc/cron.daily/daily-backup
# PARM: No parameters but /etc/ssmtp/ssmtp.conf must be setup

# NOTE: Backup file name contains machine name + Distro
#       Same script for user with multiple dual boot laptops
#       Single machine should remove $HOSTNAME from name
#       Single distribution should remove $Distro

sleep 30 # Wait 30 seconds after boot

# Running under WSL (Windows Subsystem for Ubuntu)?
if cat /proc/version | grep Microsoft; then

today=$( date +%Y-%m-%d-%A )
/mnt/e/bin/ Daily-$(hostname)-$Distro-backup-$today

My is only 35% full (out of 15 GB) so my daily backups can run for awhile more before I have to delete files. But rather than an β€œeverything older than xxx” philosophy I’ll use a grandfather-father-son strategy as outlined here: Is it necessary to keep records of my backups?. In summary:

My purging process will be complicated by the fact I’ll have to learn Python and install a Python library to manage gmail folders.

If you don’t want generational backups and want to purge files older than 2 months this answer will help: Find not removing files in folders through bash script.

In summary:

find $BACKUP_DIR -maxdepth 1 -mtime +"$DAYS_TO_KEEP" -exec rm -rf {} \;
⇧ Ubuntu 18.04 restore backup failed Long boot times on 18.04  β‡©