GithubHelp home page GithubHelp logo

aiatamai / rcloned Goto Github PK

View Code? Open in Web Editor NEW

This project forked from resipsadude/rcloned

0.0 0.0 0.0 11 KB

Bash scripts for near real-time mirroring of your data to the Cloud using rclone (https://github.com/ncw/rclone)

Shell 100.00%

rcloned's Introduction

rcloned

Bash scripts for near real-time mirroring of your data to the Cloud using rclone (https://github.com/ncw/rclone)

Description

I'm not much of a programmer but this works for my needs as all I have is a small office. I hacked some Bash code together with pretty much toothpaste and duct tape and did not comment it that well at all.

As a point of reference my data on my linux box (running CentOS 7) is in /dataEncrypted/Folder 1/ ; /dataEncrypted/Folder 2/ ; etc. I use EncFs for the encryption/decryption and the decrypted folder is /data. And my Cloud data (in rclone format) is in acd:/Folder 1/ ; acd:/Folder 2/ ; etc.

You'll need to install inotifywait (for Centos 7 it's inotify-tools from the EPEL repo) and perl and perhaps some other dependencies and modify the scripts to fit your data location and rclone config. I then placed all the scripts in /etc/local/sbin/ and then chmod +x.

Then, its as simple as "rcloned start", "rcloned status", "rcloned stop". The logfile is /var/log/rcloned.log.

There are two Bash scripts that do all the work: rclonedWatcher looks for any writes to any file within a folder, recursively, and puts those filenames in a pipe: /tmp/rcloned. rclonedProcessor looks for any filenames in that pipe, every 15 seconds, and uploads all the files in the pipe, one by one, to the Cloud.

I use 2 cron jobs. The first one runs every minute and thereby starts rclonedWatcher and rclonedProcessor and checks to ensure all processes are running, and will restart all processess if any processs crashes. The last one runs every night at midnight to fix anything missed by the rclonedWatcher and rclonedProcessor. And since I only have rclonedWatcher looking for writes (and nothing else), the last cron job also takes care of file deletions, filename changes, file moves, etc.

We also need to create a symlink specific to our midnight cron job as we can't use "-f" with pgrep in a crontab as it will match against "sh" which runs the cronjob. So I did "ln -s /etc/local/sbin/rclone /etc/local/sbin/rcloneNightly". Now we can use pgrep with "rcloneNightly".

* * * * * /usr/local/sbin/rclonedUptime

0 0 * * * folders=("/Folder 1/" "/Folder 2/"); for i in "${folders[@]}"; do [ -d "/dataEncrypted$i" ] && (pgrep "rcloneNightly" || /usr/local/sbin/rcloneNightly sync --bwlimit=1M "/dataEncrypted$i" "acd:$i"); done;

Mirroring (Not A Backup)

Remember that this is NOT a backup program. It simply mirrors your local data to the Cloud. You still need backups. I recommend taking snapshots of your data (and storing them on AT LEAST one different physical device as your main data) so you can go back in time and recover your files as they existed in the past. Why? Imagine you're working on your 100-page thesis which took you 6 months to create and which gets corrupted while saving locally for whatever reason, that corrupted file is then mirrored by rcloned to your Cloud. Congratulations, you now you have two perfect copies of a corrupt file.

rcloned's People

Contributors

resipsadude 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.