GithubHelp home page GithubHelp logo

kopperi / backup-script Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 37 KB

Script written in Bash to do incremental, full and mirror backups with rsync, using cryptsetup to mount encrypted volume.

License: GNU General Public License v3.0

Shell 100.00%

backup-script's Introduction

backup-script

What is this and why does this exist.

This script is a Bash backup script for nieche use-case. Essentially, script mounts volume, performs rsync backup based on configured parameters and couple of choises given in script. This has been created, first and foremost, for practice. This started as a mere attempt to automate mounting, backing up and unmounting encrypted volumes and now it's something more (not much but still).

Script provides incremental, mirror and full backups by default and has some pre-existing automation on managing folder-structure. See more details below.

Who is this for?

Me, and anyone else who for reason or another can't or don't want to rely on cron jobs to do their backup, while using normal or encrypted backup media. Anyone who wants to use this as base or part of something else.

Script workflow:

  1. Choose desired backup (Incremental, Mirror, Full) or Quit
  2. Identify whether target volume is encrypted or non-encrypted.
  3. Mount a defined drive with cryptsetup or just mount.
  4. Check whether folders exist and either create them, based on chosen backup type update them or let user decide what to do.
  5. Use rsync to perform actual backup based on configured parameters and rsync flags in backup.config.
  6. After successful backup, let's user choose whether to leave backup drive mounted or unmount it.

How to configure this?

All configuration parameters are located in file backup.config. Following sections should be checked before attempting to use the script:

  • FOLDERS AND FILES
  • BACKUP MEDIA Instructions are included in the file for each parameter. Other than that, you should be good to go. You can fully control rsync flags in configuration file.

Since this requires sudo, I suggest you read through the script to understand what it does. I trust it since I've created it, but you shouldn't.

How to use this

After you have set setup backup.config according to your liking, run the script with ./backup.sh. I think the easiest way to use it is alias. E.g. this in ~/.bash_aliases file:

alias backup='cd /home/user/folder/where/script/is; sudo ./backup.sh; cd;'

What could be done better?

Probably a lot. Like said, this is practice and I aim to enhance it when I have time to do so. All comments, suggestions and contributions are welcome ofcourse. The way I have come up with this is build on previous versions, and I'm sure it shows. I'd like to have any feedback that you can give on how to make it smarter and more concise. I tried to provide as much comments as I saw necessary, maybe it became bloated. :)

What doest this require to work?

This script requires superuser privileges (sudo or root) to mount volumes, to backup . Password for encrypted volume will be asked after step 2. It cannot be used as cron job since it requires user interaction. Script relies on rsync and cryptsetup. All other tools are part of standard OS installation (GNU\Linux)

This script has been tested successfully with Bash version 4.4.12.

What I intend to do when I have time:

  • Log rotation for mirror and incremental backups
  • Rotation of full backups
  • Verify that there is enough space in target media before attempting to backup.
  • Support for easier rsync to remote location (can be done now by adding needed parameters to rsync flags in backup.config)
  • FIX: Row 71: In case backup volume is already mounted, script does not (yet) verify whether mount point and drive label actually belong to the backup media (drive). Risk: Drive runs out of space. Current workaround: Delete created backup folder, unmount volume and restart script.
  • IDEA: Interactive rsync flag options(lightweight frontend), possibility to save configuration

backup-script's People

Contributors

kopperi avatar

Stargazers

 avatar

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.