Automating backups for old people

I look after the computing needs of five elderly people scattered around the country – we are all on Linux (Ubuntu & Peppermint), of course. A major problem I have is persuading them to backup and update regularly, if at all, despite my providing a script to back up everything automatically – providing they bother to run it! (So not very automatic!)

My thoughts turned naturally to crontab which is wonderfully easy to use and will execute a file of commands but does present a difficulty.

My script checks for obvious errors like the wrong or absent backup-USB-stick and then offers the user optional actions, but crontab scripts execute in the background (of course) so the user cannot interact. For desktop users, having a dedicated, separate HDD would do the trick (except when the PC is stolen) but laptop users have to use a removable USB stick.

An ideal solution would be to get crontab to open a terminal to display error messages and get responses, but although I can get crontab to open a terminal I haven’t found a way of directing output to it or receiving input.

I understand that crontab is designed for stand-alone, background operation and might not be an appropriate solution anyway, but I do need some kind of solution to deal with my recalcitrant friends. Any ideas, anyone?

After screwing up my LibreOffice installation whilst trying to use crontab for this project (and that will be another post!), I found a potentially good method which is to display a message image (e.g. *.png) on the screen for a brief period.
This is my code:


#Announce a message
espeak -s 120 "backup reminder!"

#Display a message:
eog $HOME/.bin/backup_reminder.png &
sleep 0.5s

#Display the message full-screen:
wmctrl -a "backup_reminder.png"; xdotool key F11
sleep 5s

#Close the message display:
wmctrl -a "backup_reminder.png"; xdotool key Ctrl+w

It works as follows:

  1. After speaking a message (“espeak” is very good if rather mechanical)
  2. a reminder message is displayed using the usual “Image Viewer” and
  3. is made “full-screen”.
  4. after a suitable delay, the image is closed.

This executable file works brilliantly from the terminal but when the file is referenced in crontab only the spoken message is executed - the image is not displayed.
I would be very grateful for any advice on why this is not working in crontab.
Thank you

Mark’s suggestion of installing gnome-schedule in another post ( solved this problem.
It turns out that crontab won’t normally execute display commands, but the gnome-schedule application has a facility for doing so - just tick a box for “X-application” - and it works fine. The help files on the GUI scheduler indicate that it might be possible to get the simple crontab to execute display commands via a script calling another script, but I haven’t tried it yet. In any case the gnome-scheduler is nice to use.
Another nice feature is that one can initiate “once only” timed events.

The link above provides Mark’s detailed instructions for installing/removing gnome-scheduler.

My thanks, once more, to Mark.

In the next part of this saga I first need to find the total space needed for a specified list of files to see if there is enough room on the USB stick. It’s easy enough to do this for a whole directory ( du -sc $(ls) | grep total works fine ), but for a specified list of files I need to read the list of files from a file.
For example my list of files in “files” might be:
keith@T500:~$ more files

and I would use:
keith@T500:~$ du -sc --files0-from=files | grep total
du: cannot access ‘Desktop’$‘\n’‘Misc’$‘\n’‘play’$‘\n’‘Programming’$‘\n’‘Radio’$‘\n’: No such file or directory
0 total

But it doesn’t work, as you can see, although it’s made a brave effort. I’ve tried various hacks without success and would be very grateful for advice.
Thank you.

If you want a grand total only:-

du -c $(cat /path/to/files) | tail -1 | cut -f 1

where “files” is the text file containing your list of directories.

If you want the totals for all separate directories, followed by the grand total

du -c $(cat /path/to/files) | cut -f 1

If you don’t want to loose the word “total” from the grand total:

du -c $(cat /path/to/files) | tail -1

I’m guessing you don’t want the du “-s” (summarise) option … so I left it out.

You are a genius, Mark ! Lateral thinking has never been my strong point.
I notice that cat figures prominently in the various Linux advice sites and would be a useful function to become familiar with, and I shall incorporate your code in my programme. In fact I had used a longer and somewhat roundabout method along the same lines but yours is delightfully compact.

It still rankles with me on principle that I can’t get the “–files0-from=” option to work, so as an aside, if you have any ideas on that, I would be interested to know of them. Have you used it? Perhaps it’s an unreliable feature of both du and rsync.

In the meantime: my grateful thanks, as usual.