Bernard Joseph Jean Bruno/Git gave me some ideas...

Created Sat, 06 Jan 2018 11:24:06 +0000 Modified Fri, 08 Jan 2021 16:18:38 +0000
657 Words

Git gave me some ideas…

Git gave me some ideas…

Oh! It has been a while since I have posted my first blog. Anyway, I’ve got some ideas to get your mind busy.

Recently, I did some changes on ma good’ol laptop: being a fervent lover of Linux distros I was using Manjaro Cinnamon as my daily operating system. Unfortunately, I had to cope using Windows alongside it, in a dual boot. This duality in my PL (Personal Laptop — ya! I just made up this one) made me sick. So, I destroyed everything and install a brand new operating system — Now using Manjaro XFCE. (Maybe some days I will talk a bit about the Linux world).

Let’s get to the point. Well, I had a dilemma when “destroying” everything. I had to delete all my DIY ideas on my laptop. (To be honest, I forgot to back them up — drama time! ). So, I press the “erase everything” and all my ideas vanished. Dead. Muerto. I was a bit sad about it. But my mind gets busy all the time, so I can get over it.

Now, using my new distro, I’ve got a brilliant idea… what if? I created a Version Control System where it monitors all my files then upload it to an used pc somewhere…

Pretty dope, huh? But, there are many cloud storage out there. We’ve got OneDrive, Google Drive and so on… but they are O-N-L-I-N-E.

So what if we use local machines to do that!

First, let me introduce you to inotify-tools. A command line program which notifies you when there is an event occurred in a file.

Try this (after you’ve installed it):

#!/bin/sh MONITORDIR="/must/be/an/absolute/path/" inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE do echo "File ${NEWFILE} has been created"; done

Afterwards, make it executable with chmod +x, then run it and create files in the child directory of MONITORDIR you’ve set. Got it ? Got it ?

inotify-tools have a tool called “inotifywait” in which you can monitor the file. I guess you’ve seen it.

The Flags:

-m : monitor the selected files if this flag isn’t present, once it get the first changes it stops.

**-r: **recursive — look in sub-folders if any.

**–format: **is a flag in which can specify the output of the event.

then you capture the event with a | (pipe) and output it with echo.


Now you would tell me how can I use that to store my files:

We can use Raspberry Pi as an example, or any old PC where you can install Linux on there.

First, you need to configure it and install SSH on both hosts.

Once done, fix a static local IP to it.

And you use**scp**to send your files to it. You can find an example here.

Before, for security reasons, when sending files over SCP, it prompts a password. Here a quick tutorial of how to skip this.


You can replace the command:

echo "File ${NEWFILE} has been created";


scp -rp ${NEWFILE}[email protected]_host:/remote/directory/

Now you finally got you own auto-sync local cloud.

A personal monitor script which might be helpful:

inotifywait -m -r --format '%:e %w%f' /absolute/path/ | sed -n '/^CREATE/p; /^DELETE/p; /^MODIFY/p; /^DELETE/p; /^MOVE_FROM/p; /^MOVE_TO/p'