Giter Site home page Giter Site logo

mystic-cryptic's Introduction

Backup and Encrypt Script

This program provides three main functions:

  1. creates a compressed and encrypted backup of a specified directory
  2. schedules backups on a recurring basis for automated backup management using cron
  3. restores backups as needed

It keeps the latest backup of a particular folder, removing older backups to conserve storage space.

Why make this backup program?

I wanted a few different things:

  • A backup program that would compress and encrypt things
  • The freedom to select the compression and encryption algorithms
  • The ability to experiment with the best compression and encryption algorithms
  • To do all this in bash/shell (slightly works against exploring new algorithms, but I'm ok with that for now)

Installation

  1. Clone this repository to your local machine.
  2. Copy the .env.example file to .env and set the ENCRYPTION_KEY environment variable to a random string
  3. Save your encryption string somewhere where you won't lose it. You will need it to restore backups.
  4. Install lrzip (on mac osx: brew install lrzip)
  5. Run ./backup.sh to see detailed usage notes.

The other dependencies (zip and openssl are included by default on a mac).

Example Usage

Reference: backup -d [/path/to/files] -o [/where/to/put/backup] -h [hour to repeat] [-l size limit]

# a one time backup:
backup -d /Users/bae/Documents -o /Volumes/bae-back-that-up/

# a backup scheduled to re-occur at the 22nd hour of the day:
backup -d /Users/bae/Documents -o /Volumes/bae-back-that-up/ -h 22

# a backup that also filters out files larger than 100k
backup -d /Users/bae/Documents -o /Volumes/bae-back-that-up/ -h 22 -l 100k

This command will create an encrypted backup named: users_bae_documents.zip.lrz.enc.<8 hex> in /Volumes/bae-back-that-up/.

Parameter Details

  • -d: The directory to backup (required).
  • -o: The output location. The file will be named automatically (required).
  • -h: An optional hour of the day (0-23) to schedule the backup to run (optional).
  • -l: Limits the size of files that will be included in the backup (optional).

Decrypting

The restore.sh script decrypts and decompresses a backup file.

Example Usage

./restore.sh -f /path/to/files.zip.lrz.enc.12345678 -o /where/to/put/decrypted-backup

This command will take /path/to/files.zip.lrz.enc.12345678, decrypt it using the ENCRYPTION_KEY environment variable, and lrzip decompress it to /where/to/put/decrypted-backup/files.zip. The original encrypted file is retained in case of problems with the ENCRYPTION KEY. The zip file is left un-expanded, allowing the user to relocate it as needed.

Parameter Details

  • -f: The file to decrypt and decompress (required).
  • -o: The output directory. The filename is restored with the original filename (required).

Contributing

Contributions are welcome!

The issues tab has enhancement ideas and bugs. Please use that to raise any new issues, or to look for ideas on ways to contribute.

For PRs, please include:

  • the problem you're solving, as well as a link to the issue it resolves
  • an explanation of your implementation
  • details of how you tested your solution

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.