iprokin / time-machinery-sh

A very simple shell script to do backups similarly to "Back In Time" or Apple's "Time Machine"; a complementary simple script to run programs "in the past" meaning setting environmental variables so that programs see your backed up HOME folder instead of your actual one.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

time-machinery-sh

rsnapshot.sh is a very simple shell script to do backups similarly to "Back In Time" or Apple's "Time Machine"; teletime.sh is a complementary simple script to run programs "in the past" meaning setting environmental variables so that programs see your backed up HOME folder instead of your actual one.

rsnapshot.sh

rsnapshot.sh backups to your location of choice, e.g. your HOME folder. It uses rsync and cp.
Go ahead and install rsync (you probably already have it). Edit parameters in rsnapshot.sh, apply "chmod +x rsnapshot.sh" and run the script. Now you have nice little backup system.

Running it each 10 minutes will produce subfolders inside your backup folder, example:
2015-08-28--18-25
2015-08-28--18-36
2015-08-28--18-47
2015-08-28--18-57
2015-08-28--19-08
latest
Here each subfolder corresponds to a snapshot of your HOME

Running it periodically

To run backups periodically you could use 1) systemd (if you have it) 2) cron, or 3) plain bash.

1) systemd (if you have OS X or a system without systemd skip this part and go to 2-3)

With systemd, edit rsnapshot-sh.timer and rsnapshot-sh.service and put them to a folder for User level of systemd. I use /home/YOURUSER/.config/systemd/user/.
Then you enable and run timer unit with:
systemctl --user enable rsnapshot-sh.timer
systemctl --user start rsnapshot-sh.timer

2) cron

Install cron and add crontab
crontab -e

3) Plain bash

This could be usefull if you plan to run periodical backups only occasinally e.g. only when you code and want to track versions without using versioning systems or if you cannot install cron.

using watch

To run it each 10 minutes (60*10=600 seconds) do
watch -n 600 ./rsnapshot.sh
or

using loop and sleep

while true; do ./rsnapshot.sh; sleep 600; done

teletime.sh

To run programs in modified environment so backed up HOME folder appears as actual one to them.
Tricking python:
bash teletime.sh 2015-08-28--00-59 python
Tricking bash:
bash teletime.sh 2015-08-28--00-59 bash
Tricking ipython notebook:
bash teletime.sh 2015-08-28--00-59 'cd ~/YourPathTo/FolderOfChoice && ipython notebook'

You could easily search various things in your logs. For instance, you might want to search for all deleted files with:

grep "*deleting   " /run/media/ilya/BACKUPHDDNAME/backup/ilya/*/rsync.log

References

https://wiki.archlinux.org/index.php/Rsync
https://wiki.archlinux.org/index.php/Cron
https://wiki.archlinux.org/index.php/Systemd/Timers
https://wiki.archlinux.org/index.php/Systemd/User
http://learnxinyminutes.com/docs/bash/

About

A very simple shell script to do backups similarly to "Back In Time" or Apple's "Time Machine"; a complementary simple script to run programs "in the past" meaning setting environmental variables so that programs see your backed up HOME folder instead of your actual one.

License:GNU General Public License v3.0


Languages

Language:Shell 100.0%