For all of you syncing your ACD and GDrive (and the sync is already completed), I’ve compiled a little bash to make a way to quickly move your UnionFS from one to the other. Just put a file called ACDSecureTest.txt on your ACD drive, and another one called GDriveSecureTest.txt on your GDrive.
#!/bin/bash
#This script will switch the ACDSecure drive and the GDriveSecure drive in the UnionFS Mount.
#
#Define your mount points here
#
GDriveSecure="/mnt/disks/GDriveSecure"
ACDSecure="/mnt/disks/ACDSecure"
UnionFS="/mnt/disks/UnionFS"
StagingFolder="/mnt/user/Media/Staging"
#
#Begin GDriveSecure Test, then switch to ACDSecure, and test.
#
if [[ -f $UnionFS/GDriveSecureTest.txt ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: GDriveSecure mounted to UnionFS. Remounting UnionFS to ACDSecure." | tee -a "/var/log/acd-check.log"
fusermount -u $UnionFS
fusermount -u -z $UnionFS
umount -f $UnionFS
umount -l $UnionFS
sleep 2
mkdir -p $UnionFS/
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$ACDSecure=RO \
$UnionFS/
sleep 2
if [[ -f $UnionFS/ACDSecureTest.txt ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: ACDSecure Remount successful" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: ACDSecure Remount failed." | tee -a "/var/log/acd-check.log"
fi
else
echo "$(date "+%d.%m.%Y %T") GDriveSecure not currently mounted to UnionFS." | tee -a "/var/log/acd-check.log"
#
#Begin ACDSecure Test, then switch to GDriveSecure, and test.
#
if [[ -f $UnionFS/ACDSecureTest.txt ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: ACDSecure mounted to UnionFS. Remounting UnionFS to GDriveSecure." | tee -a "/var/log/acd-check.log"
fusermount -u $UnionFS
fusermount -u -z $UnionFS
umount -f $UnionFS
umount -l $UnionFS
sleep 2
mkdir -p $UnionFS/
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$GDriveSecure=RO \
$UnionFS/
sleep 2
if [[ -f $UnionFS/GDriveSecureTest.txt ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: GDriveSecure Remount successful" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: GDriveSecure Remount failed." | tee -a "/var/log/acd-check.log"
fi
else
echo "$(date "+%d.%m.%Y %T") ACDSecure not currently mounted to UnionFS." | tee -a "/var/log/acd-check.log"
fi
fi
echo "It is done."
exit
Edit: As I’ve had some input from those here, I’ve compiled a few new scripts to assist in this:
#!/bin/bash
#
#This script will test your mount points and make sure they are remounted if they should fail. If one fails, it will switch the UnionFS to the other, but not modify should the other be okay.
#Define your mount points here:
GDriveSecure="/mnt/disks/GDriveSecure"
ACDSecure="/mnt/disks/ACDSecure"
UnionFS="/mnt/disks/UnionFS"
StagingFolder="/mnt/user/Media/Staging"
PMSAppData="/mnt/user/appdata/PlexMediaServer"
#
#Begin GDriveSecure Test
#
if [[ -f "$GDriveSecure/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, GDriveSecure mounted" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: GDriveSecure not mounted remount in progress" | tee -a "/var/log/acd-check.log"
if [[ -f "$UnionFS/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ACDSecure mounted to UnionFS" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: ACDSecure not mounted to UnionFS. Remount in progress" | tee -a "/var/log/acd-check.log"
fusermount -u $UnionFS
fusermount -uz $UnionFS
umount -l $UnionFS
umount -f $UnionFS
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$ACDSecure=RO \
$UnionFS
sleep 2
if [[ -f "$UnionFS/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: ACDSecure Remount to UnionFS successful" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: ACDSecure Remount to UnionFS failed." | tee -a "/var/log/acd-check.log"
fi
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
fi
fusermount -u $GDriveSecure
fusermount -uz $GDriveSecure
umount -l $GDriveSecure
umount -f $GDriveSecure
sleep 2
rclone mount \
--allow-non-empty \
--allow-other \
--dir-cache-time 60m \
--max-read-ahead 4G \
--buffer-size 1G \
--contimeout 15s \
--low-level-retries 1 \
--no-check-certificate \
--quiet \
--stats 0 \
--retries 10 \
--timeout 10s \
--log-file=/mnt/user/appdata/PlexMediaServer/mount.log \
GDriveSecure:/ $GDriveSecure &
sleep 2
if [[ -f "$GDriveSecure/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: GDriveSecure Remount successful" | tee -a "/var/log/acd-check.log"
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$GDriveSecure=RO \
$UnionFS
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: GDriveSecure Remount failed." | tee -a "/var/log/acd-check.log"
fi
fi
#
#Begin ACDSecure Test
#
if [[ -f "$ACDSecure/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ACDSecure drive mounted" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: ACDSecure Drive not mounted remount in progress" | tee -a "/var/log/acd-check.log"
if [[ -f "$UnionFS/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, GDriveSecure mounted to UnionFS" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: GDriveSecure not mounted to UnionFS. Remount in progress" | tee -a "/var/log/acd-check.log"
fusermount -u $UnionFS
fusermount -uz $UnionFS
umount -l $UnionFS
umount -f $UnionFS
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$GDriveSecure=RO \
$UnionFS
sleep 2
if [[ -f "$UnionFS/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: GDriveSecure Remount to UnionFS successful" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: GDriveSecure Remount to UnionFS failed." | tee -a "/var/log/acd-check.log"
fi
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
fi
fusermount -u $ACDSecure
fusermount -uz $ACDSecure
umount -l $ACDSecure
umount -f $ACDSecure
sleep 2
rclone mount \
--allow-non-empty \
--allow-other \
--dir-cache-time 60m \
--acd-templink-threshold 0 \
--max-read-ahead 4G \
--buffer-size 1G \
--contimeout 15s \
--low-level-retries 1 \
--no-check-certificate \
--quiet \
--stats 0 \
--retries 10 \
--timeout 10s \
--log-file=/mnt/user/appdata/PlexMediaServer/mount.log \
ACDSecure:/ $ACDSecure &
sleep 2
if [[ -f "$ACDSecure/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: ACDSecure Remount successful" | tee -a "/var/log/acd-check.log"
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$ACDSecure=RO \
$UnionFS
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: ACDSecure Remount failed." | tee -a "/var/log/acd-check.log"
fi
fi
exit
Here is another one that combines most everything here:
#!/bin/bash
#This script will monitor the mount's LogFile, and switch the ACDSecure drive and the GDriveSecure drive in the UnionFS Mount when there is a "403 Forbidden" error.
#
#Define your mount points & logfile here:
#
GDriveSecure="/mnt/disks/GDriveSecure"
ACDSecure="/mnt/disks/ACDSecure"
UnionFS="/mnt/disks/UnionFS"
StagingFolder="/mnt/user/Media/Staging"
LOGFILE="/mnt/user/appdata/PlexMediaServer/mount.log"
PMSAppData="/mnt/user/appdata/PlexMediaServer"
tail -fn0 $LOGFILE | \
while read line ; do
echo "$line" | grep "403 Forbidden" # Could probably be a bit more specific, does this always imply ban?
if [ $? = 0 ] ; then
sleep 5
#This script will test your mount points and make sure they are remounted if they should fail. If one fails, it will switch the UnionFS to the other, but not modify should the other be okay.
#Begin GDriveSecure Test
if [[ -f "$GDriveSecure/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, GDriveSecure mounted" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: GDriveSecure not mounted remount in progress" | tee -a "/var/log/acd-check.log"
if [[ -f "$UnionFS/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ACDSecure mounted to UnionFS" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: ACDSecure not mounted to UnionFS. Remount in progress" | tee -a "/var/log/acd-check.log"
fusermount -u $UnionFS
fusermount -uz $UnionFS
umount -l $UnionFS
umount -f $UnionFS
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$ACDSecure=RO \
$UnionFS
sleep 2
if [[ -f "$UnionFS/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: ACDSecure Remount to UnionFS successful" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: ACDSecure Remount to UnionFS failed." | tee -a "/var/log/acd-check.log"
fi
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
fi
fusermount -u $GDriveSecure
fusermount -uz $GDriveSecure
umount -l $GDriveSecure
umount -f $GDriveSecure
sleep 2
rclone mount \
--allow-non-empty \
--allow-other \
--dir-cache-time 60m \
--max-read-ahead 4G \
--buffer-size 1G \
--contimeout 15s \
--low-level-retries 1 \
--no-check-certificate \
--quiet \
--stats 0 \
--retries 10 \
--timeout 10s \
--log-file=/mnt/user/appdata/PlexMediaServer/mount.log \
GDriveSecure:/ $GDriveSecure &
sleep 2
if [[ -f "$GDriveSecure/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: GDriveSecure Remount successful" | tee -a "/var/log/acd-check.log"
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$GDriveSecure=RO \
$UnionFS
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: GDriveSecure Remount failed." | tee -a "/var/log/acd-check.log"
fi
fi
#
#Begin ACDSecure Test
#
if [[ -f "$ACDSecure/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ACDSecure drive mounted" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: ACDSecure Drive not mounted remount in progress" | tee -a "/var/log/acd-check.log"
if [[ -f "$UnionFS/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: Check successful, GDriveSecure mounted to UnionFS" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") ERROR: GDriveSecure not mounted to UnionFS. Remount in progress" | tee -a "/var/log/acd-check.log"
fusermount -u $UnionFS
fusermount -uz $UnionFS
umount -l $UnionFS
umount -f $UnionFS
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$GDriveSecure=RO \
$UnionFS
sleep 2
if [[ -f "$UnionFS/GDriveSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: GDriveSecure Remount to UnionFS successful" | tee -a "/var/log/acd-check.log"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: GDriveSecure Remount to UnionFS failed." | tee -a "/var/log/acd-check.log"
fi
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
fi
fusermount -u $ACDSecure
fusermount -uz $ACDSecure
umount -l $ACDSecure
umount -f $ACDSecure
sleep 2
rclone mount \
--allow-non-empty \
--allow-other \
--dir-cache-time 60m \
--acd-templink-threshold 0 \
--max-read-ahead 4G \
--buffer-size 1G \
--contimeout 15s \
--low-level-retries 1 \
--no-check-certificate \
--quiet \
--stats 0 \
--retries 10 \
--timeout 10s \
--log-file=/mnt/user/appdata/PlexMediaServer/mount.log \
ACDSecure:/ $ACDSecure &
sleep 2
if [[ -f "$ACDSecure/ACDSecureTest.txt" ]]; then
echo "$(date "+%d.%m.%Y %T") INFO: ACDSecure Remount successful" | tee -a "/var/log/acd-check.log"
mkdir -p $UnionFS
sleep 2
unionfs \
-o cow,allow_other,direct_io,auto_cache,sync_read,nonempty,hide_meta_files \
$StagingFolder=RW:$ACDSecure=RO \
$UnionFS
#This will restore any items that may have accidentally gotten trashed during the last mount failure.
sqlite3 $PMSAppData/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items set deleted_at=null"
else
echo "$(date "+%d.%m.%Y %T") CRITICAL: ACDSecure Remount failed." | tee -a "/var/log/acd-check.log"
fi
fi
echo "The UnionFS Switch has been completed."
#This moves the log file so that it the script does not keep looping
mv $LOGFILE "$LOGFILE $(date)"
fi
done