Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Weekly Server Backup to Google Drive

A simple bash script that takes a full backup of a Linux server and uploads it to Google Drive using rclone, keeping only the latest backup on the remote (each new upload replaces the previous one).

What it does

  1. Creates a tar.gz archive of the whole filesystem (excluding volatile/pseudo paths like /proc, /sys, /dev, /tmp, /run, /mnt, /media, /var/cache, and the local backup working directory).
  2. Uploads the archive to a Google Drive folder via an rclone remote.
  3. After a successful upload, deletes any older backup files in that remote folder, keeping only the newest one.
  4. Removes the local archive copy so it doesn't fill up server disk space.
  5. Logs every run to /var/log/weekly-backup.log.

Requirements

Setup

# Place the script
mkdir -p /root/scripts
cp weekly_backup.sh /root/scripts/weekly_backup.sh
chmod +x /root/scripts/weekly_backup.sh

# Test it manually
/root/scripts/weekly_backup.sh

# Schedule it weekly, e.g. every Sunday at 03:00
(crontab -l 2>/dev/null; echo "0 3 * * 0 /root/scripts/weekly_backup.sh >/dev/null 2>&1") | crontab -

Configuration

Edit the variables at the top of weekly_backup.sh to fit your setup:

Variable Default Description
BACKUP_DIR /root/backups Local staging directory for the archive
REMOTE gdrive:server-backups rclone remote path where backups are uploaded
LOG_FILE /var/log/weekly-backup.log Log file path

Notes

  • The script only ever touches files inside the REMOTE folder on Google Drive — nothing else in your Drive is read, modified, or deleted.
  • tar exit code 1 (files changed while reading, common on a live system) is treated as non-fatal; any other non-zero exit aborts the backup.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages