#backup #amazon-s3 #mailgun #user #home #file #forge

bin+lib forge_backup

A program to backup all the user home folders to an S3 bucket

10 releases (1 stable)

1.0.0 Jun 13, 2024
0.9.0 Jun 13, 2024
0.8.0 Jun 13, 2024

#562 in Filesystem

Download history 9/week @ 2024-07-21 22/week @ 2024-07-28 30/week @ 2024-09-22

177 downloads per month

MIT license

26KB
583 lines

Forge Backup

forge_backup is a backup application for Linux servers. I developed this for Laravel Forge servers, however it will work with any linux server. It will backup each users home folder into a temp folder and then upload that to an AWS S3 Bucket, deleting the temp file on completion. It will also use Mailgun API to report any failures (or success by configuration).

Requirements

  • Rust 1.74 or newer
  • libssl-dev (on Debian-based systems) or openssl-devel (on Amazon Linux)
  • zip
  • aws-cli
  • Configured AWS CLI with access keys (aws configure)

Rust toolchain

To install the rust toolchain, run the following command

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Installation

To install forge_backup, ensure you have the Rust toolchain installed, then run:

cargo install forge_backup

Usage

To use forge_backup, run the following command:

forge_backup [OPTIONS]

Options

  • --temp-folder <TEMP_FOLDER>: Specify where to create the temp archives.
  • --s3-bucket <S3_BUCKET>: Specify the S3 bucket for backups.
  • --s3-folder <S3_FOLDER>: Specify the folder in the S3 bucket.
  • --home-dir <HOME_DIR>: Specify the home directory to back up (default: /home).
  • --notify-success <NOTIFY_SUCCESS>: Notify on success (possible values: true, false).
  • --alert-email <ALERT_EMAIL>: Email to alert in case of failure.
  • --exclude-users <EXCLUDE_USERS>: Users to exclude from backup.
  • --hostname : Specify the hostname.
  • -h, --help: Print help information.
  • -V, --version: Print version information.

Example

forge_backup --s3-bucket my-backup-bucket --s3-folder daily-backups --notify-success true --alert-email admin@example.com

Configuration

You can create a configuration file at ~/.config/forge-backup/forge_backup.toml. The command-line parameters will override the config file values. Following is a template for the config file.

exclude_users = []
exclude_files = [
    "**/ai1m-backups/*",
    "**/node_modules/*",
    "**/.cache/*",
    "**/.npm/*",
    "**/vendor/*",
]
temp_folder = "~/tmp/backups"
home_dir = "/home"
hostname = "{$HOSTNAME}"
s3_bucket = ""
s3_folder = "daily"
alert_email = ""
notify_on_success = false
mailgun_api_base = ""
mailgun_api_key = ""
mailgun_domain = ""
sender_email = ""

Environment Variables

Environment variables can be used in the config file like this:

hostname = "{$HOSTNAME}"

Contribution Guidelines

We welcome contributions. Please follow these guidelines:

  1. Fork the repository and clone your fork.
  2. Create new branch for your feature or bugfix.
  3. Make your changes and test thoroughly.
  4. Commit your changes with clear and descriptive commit messages.
  5. Push your branch to your forkl.
  6. Open a pull request and describe your changes.

License

This project is licensed under the MIT License.

Issues and Feature Requests

If you encounter any issues or have feature requests, please submit them on our GitHub Issues page.

Contact

For any questions or support, please feel free to reach out via GitHub.

Thank you for using forge_backup!

Dependencies

~13–49MB
~751K SLoC