Skip to content

Latest commit

 

History

History
92 lines (72 loc) · 3.2 KB

README.md

File metadata and controls

92 lines (72 loc) · 3.2 KB

🎯 Backup-to-Remote Scripts (Rclone powered)

This suite of scripts is designed to manage backups of application directories, upload them to a remote server, clean up old backups, and publish statistics on storage usage. Below is a brief overview of each component and its purpose.

📁 Scripts Overview

1. backup.sh

Performs backups of specified application directories:

  • Checks for changes in the directories.
  • Creates a backup only if changes are detected.
  • Uploads the backup to remote storage.
  • Cleans up old backups locally and remotely.
  • Usage: ./backup.sh

2. upload.sh

Uploads a specified archive file to a remote location using rclone:

  • Verifies the upload by checking the existence of the file on the remote.
  • Deletes the local archive if the upload is verified.
  • Usage: ./upload.sh <path-to-archive>

3. cleanup.sh

Cleans up old backup files both locally and remotely:

  • Retains a specified number of the most recent backup files on the remote server.
  • Removes old .zip files from the local backup directory.
  • Usage: ./cleanup.sh

4. stats.sh

Generates and displays storage statistics for the remote backup folder:

  • Lists all files and their sizes.
  • Shows total occupied space and remaining space.
  • Usage: ./stats.sh [remote-path]

🔧 Dependencies

Ensure you have the following installed:

  • rclone for managing remote storage.
  • zip for creating backups.
  • find and stat for file modification checks.
  • diff for comparing file states.

🌟 Configuration

Configuration settings are managed through the .env file. Here’s a summary:

  • LIST_FILE: Path to the file containing application directories for backup.
  • LOCAL_BACKUP_PATH: Local directory for temporary backups.
  • UPLOAD_SCRIPT: Path to the upload script.
  • CLEANING_SCRIPT: Path to the cleaning script.
  • STATS_SCRIPT: Path to the statistics script.
  • COPIES_TO_KEEP: Number of backup copies to retain on remote storage.
  • RCLONE_CONFIG_PATH: Path to the rclone configuration file.
  • RCLONE_CONFIG_NAME: Name of the rclone remote configuration*.
  • REMOTE_PATH: Remote path in the rclone configuration.

* Configure rclone remote configuration file using:

rclone config --config ./rclone.conf

Follow the prompts to configure your remote storage and save the configuration

📦 Installation

1. Clone this repository:

git clone https://github.com/keshon/backup-to-remote.git
cd https://github.com/keshon/backup-to-remote.git

2. Create and configure your .env file:

cp .env.example .env

Edit .env to set your configuration values (see 🌟 Configuration section above)

3. Make sure all scripts are executable:

chmod +x backup.sh upload.sh cleanup.sh stats.sh

4. Fill out the .env file:

Check the 🌟 Configuration section above

🚀 Running the Scripts

Main script:

  • Backup: ./backup.sh

Additional scripts (used by backup.sh or independently of it)

  • Upload: ./upload.sh
  • Cleanup: ./cleanup.sh
  • Statistics: ./stats.sh [remote-path]

For more detailed information on each script, refer to the comments within the scripts themselves.