If the designated destination drive is unmounted, Grsync fills up the o/s partition instead of just mounting it, or aborting. How do I prevent that?
I usually remember to check to see that it's mounted, but sometimes I forget, with very bad results.
Thanks for any help.
ra@ra-main:~$ cat /etc/fstab
/etc/fstab: static file system information.
Use 'blkid' to print the universally unique identifier for a
device; this may be used with UUID= as a more robust way to name devices
that works even if disks are added and removed. See fstab(5).
/ was on /dev/sdc3 during installation
UUID=557ba3eb-2dcc-4b03-964b-f12f509c4faa / ext4 errors=remount-ro 0 1
/boot/efi was on /dev/sda3 during installation
#UUID=D305-EBF0 /boot/efi vfat umask=0077 0 1 /swapfile none swap sw 0 0 UUID=0399-667C /boot/efi vfat defaults 0 1 LABEL=Grsync /mnt/Grsync auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=Grsync 0 0 ra@ra-main:~$ ^C
Yes, that's the intended behavior of grsync, rsync, etc., and many other backup tools and it is the user's responsibility to check that the volume is mounted prior to executing these tools (as you allude to). You can create a script that runs the grsync command instead of running it directly, and then put some commands that check to see if the volume is mounted before running the grsync command (or just run the mount check commands manually, that works too). Something like this might work:
cd /home/username/
mkdir scripts
cd scripts
nano grsyn.sh
sudo chmod 750 grsync.sh
nano grsync.sh
Then, in the file that opens in the nano text editor, copy and paste and adjust this script to your needs:
You can run the script manually by navigating to your scripts' directory and typing
./grsync.sh
. Theq
flag is optional and can be removed depending on user preference. You can optionally create a cron job to run this script as follows:sudo crontab -e
Below the last entry, copy/paste and adjust the following to your needs:
0 8 * * * /bin/bash /home/username/scripts/ >> /home/username/grsync.log
This script will run your desired grsync command every day at 8am.
New users and/or less complex workflows might only require a simple check, and in that case it is easiest to enter a single command at the console. To do that, use the grep syntax above, but just make sure to omit the
q
flag so the result prints to standard output:grep -s '/mnt/backup ' /proc/mounts
This will then print a result similar to this if the Volume is mounted:
/dev/sdb /mnt/backup ext4 rw,nosuid,nodev,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 0
If you receive no output, and as long as your grep string is accurate, then this would indicate the volume is likely not mounted. Lastly, if you want this integrated within the graphical front end of grsync instead of handling at the command line, then simply enter the manual command into the Extra Options / Execute this command before rsync / Halt on failure.