Back in the days when I worked for a living, one of the computer guys at the plant corrected me while I was talking about disc drives in our computers - I was saying "if it fails..." He corrected me with "Not if it fails. When..."
Though no longer required, lots of old-school Radio Amateurs keep a log. Some use pencil and paper, but most do it digitally (and some, like me, do both). Belt and suspenders.
With that in mind, I have written a Linux script that will help me avoid manual re-creation of my digital Amateur Radio log from the pencil and paper copy - which dates back to 1970 - when the computer finally fails. I use XLog, but this should work for other Linux logging programs.
You will need some basic familiarity with Linux scripting and permissions, have crontab up and running and Dropbox installed.
The general scheme is to copy the XLog log file to a safe place at least once a day. When my computer dies (and they all will), I could re-install XLog on a replacement and retrieve the latest of my daily log file copies kept remotely by Dropbox.
The scheme has three parts:
(1) Linux 'crontab'
(2) Dropbox
(3) The 'xlog_backup.cmd' script
'crontab'
Linux has a very handy program that allows users to schedule events at intervals. I will not do a tutorial on cron or crontab, but will just show you the appropriate crontab file entry, below:
# min hour day month day of command
# week
#
30 * * * * /home/MYHOME/bin/xlog_backup.cmd
Crontab reads this file and is directed to run the command xlog_backup.cmd (in the directory given) on the half-hour of every hour of every day of every month on every day of the week. For you old timers, that's every time Mickey's long arm points down.
Dropbox
Dropbox is a commercial file sharing and storage program. There is a fee if you want to store lots of data, but since XLog files are relatively tiny, we can just use the free ('Basic') version. Check out:
https://www.dropbox.com
You will have to create an account. The script below could possibly work with another file-sharing program that works in a similar fashion. Your decision. I have no commercial interest in Dropbox, but it is quite handy for things other than saving Amateur Radio log files.
One you have Dropbox running and understand how it works, make a subdirectory, perhaps named "XLog", to match the script location below.
'xlog_backup.cmd'
Here is the backup script. This is a revised version (23 February 2019) that is slightly more logical and creates a new backup if you change your log. You will have to edit the various lines that are unique to your application - one example is the name of XLog's log file. XLog typically keeps this file in the hidden directory '.xlog'. Mine is named wb5bkl.xlog.
Make a copy of the script below and edit it:
#!/bin/bash
# /home/urhomedir/bin/xlog_backup.cmd
#
#
### Edit each of the following for your situation:
### urhomedir - your home directory
### YOURCALL - your callsign in CAPS
### yourcall - your callsign in lowercase
### Note the asumptions about directory locations
### including the Dropbox directory structure.
### All the 'echo' statements can be commented out once
### you've got it working to your satisfaction.
#
#
# Define paths to xlog data file and Dropbox backup
YOURCALL_XLOG=/home/urhomedir/.xlog/yourcall.xlog
DROPBOX_XLOG=/home/urhomedir/Dropbox/Xlog/yourcall.xlog.`date +%j`
#
# Housekeeping - comment this out if you want to keep them all
# Get rid of all but the 10 most recent log backups
rm -f $(ls -1t /home/urhomedir/Dropbox/Xlog/yourcall.xlog* | tail -n +11)
#
#
# First, check to see if the backup for today exists
# If not, create it and exit
#
#
if [ ! -f $DROPBOX_XLOG ]
then
# create it
cp $YOURCALL_XLOG $DROPBOX_XLOG
echo -e "\n Creating today's backup file: yourcall.xlog.`date +%j` \n"
# place a note in .xlog containing the latest backup time
date > ~/.xlog/Last_Cloud_Backup
exit
else
:
fi
#
# Or see if the logfile in Dropbox is newer than your logfile
# If so, do nothing and quit
#
if [ $DROPBOX_XLOG -nt $YOURCALL_XLOG ]
then
echo -e "\n yourcall.xlog.`date +%j` exists and is newer."
echo -e " Quitting xlog_backup.cmd...\n"
exit
else
# if the Dropbox version is older than the logfile, overwite it
# with the newer version
cp $YOURCALL_XLOG $DROPBOX_XLOG
echo -e "\n Overwriting today's backup file: yourcall.xlog.`date +%j` \n"
# place a note in .xlog containing the latest backup time
date > ~/.xlog/Last_Cloud_Backup
fi
#
exit
#
Save the edited copy in your 'bin' directory (or wherever - but match your crontab entry) and make it executable. The script only makes one Dropbox copy per day - but overwrites that copy if your log changes within the last hour. Safe enough for me - but you can modify the if/then routine above and the crontab entry to suit your needs.
The backup file will have the name yourcall.xlog.Julian_date, for example: wb5bkl.xlog.147
And the the latest backup time will be noted in your .xlog directory. Backups from at least the last 10 days will be saved.
I hope this works for you - and keeps your log(s) nice and safe.
cln - Nick
WB5BKL
Lake Buchanan
Showing posts with label logging. Show all posts
Showing posts with label logging. Show all posts
Saturday, September 22, 2018
Saturday, June 24, 2017
Adventures with a 'Thin Client' – a HP t5740
Recently I got
interested in 'thin clients'. Small PCs with no moving parts. Here
is a really good resource:
I like having
a spare small profile computer to do my Amateur Radio logging
function. The only real requirement (besides a little storage space)
was an RS-232 port (the logging program receives data from my transceiver via RS-232).
I found a HP t5740W
on eBay for $24 shipped, with power supply, 4G of ram and 4G of flash
memory.
The thin client
arrived (as expected) with no OS. I looked online for
advice about the best small footprint Linux and found that my
personal choice, Debian, was one of the top ten. I loaded a Debian
Jessie “Net Install” iso on a USB stick and gave it a try just to
see what would happen with the 4G flash memory. It fit!
But just barely -
there was very little space left, maybe 11% or so after installing the logging program, XLog. That's a little
tight, even for my tiny ham radio app. I decided to attempt the
installation of a disc drive, as mentioned in the “Mods” section
of the 'Thin Clients' website above. Here's the SATA connector on the motherboard.
That's an odd connector. I am very lucky to
have a Goodwill Computer Store fairly close. The knowledgeable folks
there helped me pick out some potential 'donor' cables and the smallest 2.5” SATA drive they had (160Gb).
Another $10 invested. Cheap works for me.
I followed the guide
in the mods section for the HP t5740 (drill down: Home – Details –
HP, etc). The big gotcha is the SATA data and power cables. Both
must be modified to fit the connector on the mother board. Here is
an image of a before and after mod for the data cable. The power
cable will need a similar mod.
Click to enlarge the image. All the Xacto wounds have now healed. Note: Band-Aids are remarkably difficult to apply if the cut is on your thumb...
Photos in the mods section mentioned above show the installation of the drive better than I can. I did move the RAM memory as suggested.
Success! I now have two installations of
Debian Jessie on the t5740, one on the 160Gb hard drive and one on
the 4Gb flash memory. Via Grub, I can boot to either.
Had fun.
cln – Nick
WB5BKL
Labels:
Amateur Radio,
Debian,
H-P,
Ham,
HP,
logging,
SATA cable,
t5740,
thin client,
WB5BKL,
XLog
Subscribe to:
Posts (Atom)




