Bash-script to automatically back up files in a given list via git version control
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Victor Giers 90f88023c7 fixed bug that occured due to commenting out log-function vor 1 Jahr
README.md readme fixed vor 1 Jahr
backup_filelist.txt initial commit vor 1 Jahr
backup_routine.sh fixed bug that occured due to commenting out log-function vor 1 Jahr
log.txt fixed bug that occured due to commenting out log-function vor 1 Jahr

README.md

This script checks if changes happened to a given list of files, and if so, it’ll store them into a next version as back up.

Setup

Install git.
Create a folder that should act as your automatic archive.
Open that folder with your terminal and execute git init
Create a file in the folder called “.gitignore” and put the following in it:

backup_routine.sh
backup_filelist.txt

Create the files “backup_routine.sh” and “backup_filelist.txt” in this folder.
Copy the code from “backup_routine.sh” in this repository into yours.
Put the complete filepaths to the files you want to automatically be versioned into “backup_filelist.txt”.
Now use git add * and git commit -m "initial commit"
You’re done setting up your automatic archive.


Automation

Make it so that “sh backup_routine.sh” gets called automatically. I recommend setting up a cron job, for example by executing EDITOR=nano crontab -e and writing the following into crontab:

0,15,30,45 * * * * cd ~/Automatic\ Git\ Versioned\ Backups && sh backup_routine.sh

This will run the script every 15 minutes.


Restoration

Use

git log -- filename.ext

to view all the past versions.
Copy the commit-id of the version you wish to restore.
To recreate a past version, use

git show commit-id:filename.ext > path/to/restoration/filename.restored.ext

For example: git show 8f1dc7362dd5f6781ccf9ccc5a9cfdccb57ed709:ToDo.xlsx > ToDo.restored.xlsx