02.01
EDIT: there’s actually a silly bug in this one. I’ve fixed it in dev, but hey, who cares about getting around to making a new post ^^-))
My little backup script thingy has been completed, and ofc I’ve become inspired to make it more than it was. This is a great exercise to see if I can still knock these things out, I mean, I’m not a scripter or have any real programming background to speak of. There are new criteria for the version 0.4 of the script.
teedlescript criteria
DONE * runs in manual or non-manual (eg cron) mode, configurable in a variable.
DONE * pulls the content of a (configurable) directory into a tar archive, compresses it on the fly with gzip and stores it in another (configurable) directory.
DONE * detects if the run is the first one (eg backup is mandatory) otherwise it checks to see if the configured directory that should be backed up has changed size. If it has, the script will backup the dir, otherwise it won’t.
DONE * detects the size of the backup, and will write a warning if the size of the target dir is less than twice the size of the backup, and will write an error and fail if the size of the target dir is equal or less than the estimated size of the backup.
DONE * has a a lock file scheme, eg prevents the script starting while another instance of it is running
DONE * has an email scheme, ie you get a “backup was successful || failed miserably” email to a mailbox you configure in the script.
DONE * do something snazzy when run in manual mode to show the user that the script is actually still running hehe
* implement passwordless scp copy to a configured remote machine…..maybe
* asks the user questions at first run about what variables need filling
* check for presence of external variable file
* is flexible about the location of the variable file in case the user is allergic to /usr/local/etc
* test for everything eg extreme paranoia, assume nothing
I’ll be working on it if I have time
oh, yes, for those curious to what it looks like (or wanting to point out how bad I am at scripts hehe) you can see the thing here
README:
put the script somewhere on your linux server.
copy it somewhere sensible like /usr/local/bin
make sure that it can be executed (chmod +x)
edit some variables (vi /usr/local/bin/teedlebackup):
this is where your stuff is you want to backup: SOURCE=/my/important/stuff
this is where you want your backup to go: TARGET=/my/backups
manual mode or not; 1=on 0=off (eg using cron) MANUAL=1
leave ADDY= blank for now
once you’ve tested it and it seems to work, change MANUAL=1 to MANUAL=0
if your account can mail, put a valid email address here and it will mail you ADDY=myself@mydomain.tld
set up your cron or root’s cron or whatever to run at a time you’d enjoy (crontab -e). example:
15 0 * * 1 /usr/local/bin/teedlebackup
^^ runs teedlebackup every monday at quarter past zero in the morning
if you are running it automated, and did not fill in your email, it will also leave messages for you in the system’s main logfile, which is usually /var/log/messages. you can look at the logfile with the tail or cat commands.
Enjoy!



No Comment.
Add Your Comment