Giter Site home page Giter Site logo

rsyncbackup's Introduction

rsyncBackup For NAS

rsycBackup is a script for helping create a redundant copy of your data from one SOURCE NAS to a DESTINATION NAS, as an automated script run from the DESTINATION system, not altering any of the data from the SOURCE.

This differs from current solutions, as this process is run completely from the DESTINATION unit, allowing the user to automate power-on, backup process, and shutdown of the NAS unit.

Features

  • Secure offline storage
  • Backup run from the DESTINATION device, allowing granular control with timing and permissions
  • Protection from ransomware and other attacks

Getting Started

There are a few prerequisites and safety precautions to consider before running the script. By default, the script is set to TEST, which will help you with the setup and testing before implementation.

Prerequisites

Some things you should have in place before you get started:

  • basic working knowledge of linux
  • knowledge of ssh and key-pair authentication
  • knowledge of scp, tar, vi/vim
  • Python 2.7 installed on the NAS running the script
  • Pyyaml (version 3.11)

You will need SSH enabled on both NAS units, with key-based authentication set up for the user specified in the settings.yaml file.

  • It's recommended to add a custom ssh port number for security if your NAS unit is open to the internet.

  • If you're having issues with key-based authentication, Copy the sshd_config into the homes/[USER]/.ssh directory

Installation

Once key-based ssh is working, script installation is simple. There are 4 files included:

  • sources.conf A line-by-line text file of backup paths
  • exclusions.conf A line-by-line text file of path and expression based exclusions
  • settings.yaml A YAML file of values to control the syncing operation. MUST BE IN THE SAME DIRECTORY AS THE MAIN PYTHON SCRIPT
  • rsyncBackup.py The python script that will execute the backup
  1. Copy the files into a subdirectory that will be excluded from the process in step 4:
/volume1/homes/rsync/rsyncBackup
  1. Edit the settings.yaml file to conform to your file system and setup. Each variable has a descriptive comment explaining it's function.

  2. Add the source directories you wish to copy into the sources.conf file, excluding the /volume#/ root specified in the settings.yaml:

Public/
Private/
TimeMachine/
  1. Verify the exclusions set in the exclusions.conf file, using:
  • literal string, wildcard, or character range
  • lines beginning with / will be explicit exclusions, and are listed relative to the source directory.
#If the source directory is Public/
/Public/Documents           <- BAD!!!
/volume1/Public/Documents   <- BAD!!!
/Documents                  <- GOOD
  • Trailing slash is a directory (not a file). No trailing slash can be a directory or a file.
lost+found
.ssh*
*recycle
/path/to/exclusion

Deployment

This can be run as a manual process from the terminal with admin privilages, or launched as an automated task from a task scheduler. Keeping an offline backup is easy to automate:

  1. The SOURCE system runs a scheduled task to wake the DESTINATION system. Ensure that your WOL ports are accessible for this to work.
#!/usr/bin/env bash
# On a Synology NAS unit - Wake On LAN commands will vary between systems.
synonet --wake [MAC ADDRESS] eth0;
  1. The DESTINATION system begins running the on-boot scheduled rsyncBackup.py process
  2. The DESTINATION system settings.yaml is set to shutdown after completion
  3. Logs are compressed and archived for reference

Sources

Built With

  • python - if you don't know, now you know.
  • pyYaml - PyYAML is a YAML parser and emitter for Python (3.11).
  • rsync - a fast, versatile, remote (and local) file-copying tool
  • ssh - OpenSSH SSH client (remote login program)
  • tar - GNU 'tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive.

Contributing

Please contact me with any pull requests!

Authors

Pixelpicnic

With feedback from: antipyretiquel

License

This project is licensed under the GNU GPLv3 License - see the GNU GPLv3 License for details

Acknowledgments

https://primalcortex.wordpress.com/2016/01/25/synology-installing-python-pip-package-installer/

https://stamler.ca/enable-passwordless-ssh-on-synology-dsm6/

https://sites.google.com/site/rsync2u/home/rsync-tutorial/the-exclude-from-option

https://www.endpoint.com/blog/2015/01/28/getting-realtime-output-using-python

Purplebooth README.md template

rsyncbackup's People

Contributors

pixelpicnic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

changlun65

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.