It is 2022-07-07 today. Two days ago I’ve stupidly and accidentally lost literally all data from this server including this blog and some pet projects.
There was no regular backuping. All backups I had at the moment was dated may which is better than nothing at all. Well, either I became very tidy in my tech skills or life still teaches me nothing ¯\_(ツ)_/¯
I set up server from scratch and deployed my projects again from those backups. It took me about several hours during two days. Unfortunately, I absolutely don’t remember exactly what has been permanently lost. Shit happens.
Before that accident I didn’t bother with backups: I already have some ones, server is (almost) always stable and fine, bills are always paid in time, what may happen? This was wrong laziness.
This time I was lazy properly, as any tech guy should: if you don’t want to spend time on boring routine — automate it and don’t spend.
Since my VPS deployed without any containers-n-shit, my solution will be simple too: bash + mysqldump + gzip + rsync + crontab + second VPS as reserve remote storage.
This second you maybe already understand what I will do and talk about because our grandfathers already
At this second, you maybe already understood what I’ll do and tell and decided to close the tab, because even your grandfather didn’t do backups like that. Well, I don’t give a shit and anyway will tell my solution and attach gist which is ready to use.
Hi. In my spare time, I write a project for work purposes, which consists of a bunch of bash scripts. There is one entry point that connects the rest of the functionality via ‘source’. They contain functions that should only process the required arguments directly from the cli.
In early versions of the project, I just explicitly passed $1, $2, $N from top to bottom to other functions. It was a stupid solution, and it worked because the possible arguments and their order were known and simple. But it was disgusting aesthetically. I wanted to enjoy reading code and to unify a lot of things. To do this, the entire code had to be greatly complicated to make everything conceptually much simpler.
So, different functions must accept different arguments from input, and also I want to give to user an ability to pass:
long arguments with no values: ./script.sh --foo --bar
long arguments with values: ./script.sh --foo = bar
short arguments without values: ./script.sh -a -b -c
short arguments with values: ./script.sh -a avalue -b bvalue
combine any short short arguments into one word: ./script.sh -abc bvalue
all of above ones at the same time!
the order of the arguments shouldn’t matter
I hould have access to any of them from anywhere at any time.