Re: K3B for backups



On Thu, 3 Jan 2008, houghi wrote:-

David Bolt wrote:
You should test if they are logged in via CLI.

I had that before. I took it out because Chris point out it required a
terminal to be open and, apparently, he doesn't always have one open[0].

Check user in GUI -> OK? -> run popup
-> NOK? -> check user in CLI -> OK? -> run warning

You also need to make sure the user can actually receive the messages.
See man mesg.

-> NOK? -> send mail

Well, apart from making drinks, or performing sexual favours, I think
this revision should suffice:

#!/bin/bash

# for debugging purposes
#
#set -x

# set this to the USB device name
#
USB_DEVICE_ID="MP3_PLAYER"

# set this to the "flag" file
# if this file is present under /media/${USB_DEVICE_ID}/
# assume the device is already plugged in
#
FLAG_FILE="test"

# Which user do we want to bother
#
WHO_TO_BOTHER="davjam"

# What to display in the warning dialog box
#
DIALOG_TEXT="Please connect on the USB drive"


KDIALOG=""
ZENITY=""

# one hour timeout of the use being present
#
TIMEOUT=$[$(date +%s) + 3600]

# now test to see if the flag file is present
#
# this is true if it isn't present
#
if [ ! -e "/media/${USB_DEVICE_ID}/${FLAG_FILE}" ]
then

while [ "$(date +%s)" -lt "${TIMEOUT}" ]
do
# find out if the one we want to bother is logged in on a desktop
#
# Only use the first one they're using though
#
WANTED=$(w | grep "${WHO_TO_BOTHER}" | grep " :"| head -1)


if [ -z "${WANTED}" ]
then

WANTED=$(w | grep "${WHO_TO_BOTHER}" | grep " pts/"| head -1)

fi

THEIR_TERMINAL=$(echo "${WANTED}"|awk '{print $2}')

[ -n "${WANTED}" ] && break

sleep 4m 55

done

if [ -z "${WANTED}" ]
then

cat <<_EOF_ | mail -s "Backup script failed" "${WHO_TO_BOTHER}"
As you aren't logged in to receive the request to connect the USB drive,
and the drive isn't connected, the backup hasn't been performed.
_EOF_
exit 1
fi

echo "${THEIR_TERMINAL}"

case "${THEIR_TERMINAL::1}" in
:) # GUI in use so use a warning dialog
KDIALOG=$(which kdialog)
[ -z "${KDIALOG}" ] && ZENITY=$(which zenity)
if [ -n "${KDIALOG}" ]
then
kdialog --display "${THEIR_TERMINAL}" --warningcontinuecancel \
"${DIALOG_TEXT}"
else
if [ -n "${ZENITY}" ]
then
zenity --display="${THEIR_TERMINAL}" --question --text \
"${DIALOG_TEXT}"
else
xterm -display "${THEIR_TERMINAL}"
echo "${DIALOG_TEST}" | \
write "${WHO_TO_BOTHER}"
fi
fi
;;
p)
if [ "$(whoami)" == "${WHO_TO_BOTHER}" ]
then
mesg &>/dev/null
else
if [ "$(whoami)" == "root" ]
then
su -c mesg "${WHO_TO_BOTHER}" &>/dev/null
else
[ 0 -eq 1 ]
fi
fi
if [ "$?" -eq 0 ]
then
echo "${DIALOG_TEST}" | \
write "${WHO_TO_BOTHER}" "/dev/${THEIR_TERMINAL}"
else
cat <<_EOF_ | mail -s "Backup script failed" "${WHO_TO_BOTHER}"
Messages are not allowed to be received at the console.

As this is the case, I was unable to request you to connect the USB drive,
and since the drive isn't connected, the backup hasn't been performed.
_EOF_
exit 1
fi
;;
*)
cat <<_EOF_ | mail -s "Backup script failed" "${WHO_TO_BOTHER}"
As you aren't logged in to receive the request to connect the USB drive,
and the drive isn't connected, the backup hasn't been performed.
_EOF_
exit 1
;;
esac

# check for the Cancel/No and abort
#
[ "$?" -eq 1 ] && exit 1

# wait for the user to connect the drive, it to power up and be recognised
#
sleep 30

# true if it isn't there
#
if [ ! -e "/media/${USB_DEVICE_ID}/${FLAG_FILE}" ]
then

# they didn't plug the drive in, or it's not detected properly
# in which case we bail out
#
cat <<_EOF_ | mail -s "Backup script failed" "${WHO_TO_BOTHER}"
Apparently you decided not to connect up the USB drive so the backup could be
performed. As this is the case, the backup script has aborted and no backup
has been created.
_EOF_
exit 1

fi

fi

# if we get to here, eiter the drive was already present, or
# the user connected it and it's ready to accept the backup.
#
# add the rest of the backup script here
#

Oh, and before any bugs get opened on it, I'm going to close them
straight away with a WORKSFORME :-)

How about if it isn't. Maybe I should offer to perform an install of the
latest version of openSUSE, making sure the required packages are
installed :-)

That should not be too hard.
1) see that you have a partition to boot from
2) Download the openSUSE Netinstall to that
3) Edit grub/lilo to boot the next time from the correct partition
4) Edit the YaST configuration for the new installation so it
autoinstalls.
5) Reboot

What's so hard about that? It was possible to do using makeSUSEdvd,
until they changed the permissions on /boot/grub/device.map to 600.

OK, 'not too hard' might be a slight understatement. However I would say
that it isn't imposible. You could even offer it as an seperate script
that people can use to install and all you have to say is that they run
the following `sudo wget example.com/x|sh x`

And why not :-)

Just a tiny bit, especially since it's supposed to be running as a cron
job.

Mmm. OK. SO forget the instalation of openSUSE part. You can most likely
also forget the check of the installation fo KDE and such.

No, I'd keep that in as there's the slight chance that either the KDE or
Gnome base system isn't installed.

Now there's a thought. Open up an xterm and then use write to send the
message. I'll leave that as an exercise for the other viewers^wreaders.

You can even ask for a confirmation there. Yet when I think about it, if
the person is willing to use it, the person will most likely have the
required things installed.

True.

It won't. It specifically looks for a particular user-name to see if
they are logged in.

It won't now. It did before or I must have overlooked it.

I added it using the variable ${WHO_TO_BOTHER} :-)

Hey, reading back on the thread, this was a quick and simple fix for
Chris and his backup problem.

It is not a backup. It is a copy. :-D

It's still a backup copy. It would be much better if it was an
incremental backup, rather than a full backup, if only due to the speed
and space gains.

There's another thought. Don't look at me for implementing it. Despite
having a Bluetooth capable phone and dongle, I rarely have Bluetooth
turned on.

I have it turned on all the time, so I do not forget to turn it on when
I am in the car. My radio has bluetooth (and can play ogg files). Not
bad for 109EUR
http://www.novell.com/coolsolutions/feature/18684.html gives the
explanation on how to do it. Otherwise search for "linux bluetooth
proximity"

I did actually read up on it a while ago. Thought it would be useful if
it can be set so the phone and dongle are within about 2m of each other.

Good idea. So, when do we see the first draft scripts? :-)

You are doing great. :-D

I noticed >:-|


Regards,
David Bolt

--
www.davjam.org/lifetype/ www.distributed.net: OGR@100Mnodes, RC5-72@15Mkeys
SUSE 10.1 32bit | openSUSE 10.2 32bit | openSUSE 10.3 32bit | openSUSE 11.0a0
SUSE 10.1 64bit | openSUSE 10.2 64bit | openSUSE 10.3 64bit
RISC OS 3.6 | TOS 4.02 | openSUSE 10.3 PPC |RISC OS 3.11
.



Relevant Pages

  • Re: WAS Upgrading MS Office caused Word Docs to DISAPPEAR?!
    ... > installation of Office 2003 to make some of the important ... then you go recover it. ... > that got rid of these selective important word files. ... I'd consider setting them up with a backup process after it ...
    (microsoft.public.word.newusers)
  • Re: Xpress Recovery2 -The Saga nearly ended!
    ... that partition is the size of the backup. ... I think this is because my drives are SATA II. ... on the installation problem you encountered. ... The user must set up "unallocated" disk space in order for the program to ...
    (microsoft.public.windowsxp.help_and_support)
  • RE: Backup Problems
    ... Subject: Backup Problems ... Newsgroups: microsoft.public.windows.server.sbs ... follow the guide to implement the SBS integrated components installation. ...
    (microsoft.public.windows.server.sbs)
  • Re: On Bugzilla and spreading FOSS, was: Where Fedora Went Wrong...
    ... This has nothing to do with FOSS or Fedora, ... bunch of books, on line tutorials, installation guides, and other stuff ... I need a good, simple, effective backup ... to deposit the report. ...
    (Fedora)
  • Re: activate programs without reinstalling them
    ... > A mirror raid is not an altenative to a backup. ... >> responce and I will try to repair the XP installation before I ...
    (microsoft.public.windowsxp.configuration_manage)