PuppyThis forum is for the discussion of Puppy Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Not familiar with puppy but you could achieve this with bash scripting.
Create a file ".backupdrive" in the Linux_Files folders with your drives mounted.
In a bash script you can loop through the mount points and detect if that file exists, if it does then you're good and can back up to the mount point.
Code:
#!/bin/bash
# Clear our exit value, we'll set this later if we get an issue.
EXITWITH=0
# Loop through a list of mountpoints (yes, we could make this a variable but we'll keep it simple for now)
for MOUNTPOINT in sdb1 sdc2 ; do
# Test for the non-existence of our identifying file in the relevant mount point/folder
if [[ ! -f mnt/${MOUNTPOINT}/Linux_Files/.backupdrive ]] ; then
# Display an error message
echo "/mnt/${MOUNTPOINT} Drive not mounted or wrong drive."
# Override the EXITWITH value as we're going to exit when we get out the loop
EXITWITH=1
fi
done
# Now when we get here we will have set our EXITWITH to 1 if there was a problem.
# So now we just test this and if it's not equal to 0 then we exit the script.
if [ ${EXITWITH} -ne 0 ] ; then
exit ${EXITWITH}
fi
# Regular Script Continues Here
The above will check ALL the supplied mountpoints and will report which (if any) are missing.
If you want a simpler script that will just exit with an error if any of the mountpoints are missing you can use:
Code:
#!/bin/bash
for MOUNTPOINT in sdb1 sdc2 ; do
if [[ ! -f mnt/${MOUNTPOINT}/Linux_Files/.backupdrive ]] ; then
echo "/mnt/${MOUNTPOINT} Drive not mounted or wrong drive."
exit 1
fi
done
# Regular Script Continues Here
Replace the "echo" with whatever notification mechanism you'd prefer.
Hope this gives you a starting point.
Last edited by TenTenths; 02-18-2016 at 07:29 AM.
Reason: Typo in description of the simpler script, no code changes.
This worked last night, but now it says mnt/sdb1 not mounted when it is ??
Quote:
#
for MOUNTPOINT in sdb1 sdc2 ; do
if [[ ! -f mnt/${MOUNTPOINT}/Linux_Files/.backupdrive ]] ; then
gxmessage -timeout 2 "DRIVE /MNT/${MOUNTPOINT} NOT MOUNTED OR WRONG DRIVE."
exit 1
fi
done
gxmessage -timeout 2 "Got past drive check."
I've stopped leaving my backup drive mounted due to the encrypting ransomware. My backup script checks for known strings in a set of canary files before mounting the drive and starting the backup. It umounts the drive when done.
This worked last night, but now it says mnt/sdb1 not mounted when it is ??
check that whatever process you have didn't blank the .backupdrive file, or ensure that whatever user your script runs as has access to that file. For example, if you created that file as "root" you may want to chmod 644 it.
mnt/${MOUNTPOINT}/Linux_Files/.backupdrive
vs /mnt/${MOUNTPOINT}/Linux_Files/.backupdrive
Without the leading / mnt/${MOUNTPOINT}/Linux_Files/ becomes a relative path. If you run the script without being in /(root} directory the conditional will always be true.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.