dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 4e31248dab3ecea7c8a9279a751cea3cf23afe98
parent 35c84395e174b00fef95c97d8da230bb7adf3f6b
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun,  5 Apr 2020 14:28:10 -0400

cloudsync.sh: cull rsync flags

Diffstat:
Mlib/cron.avail/cloudsync.sh | 38++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/lib/cron.avail/cloudsync.sh b/lib/cron.avail/cloudsync.sh @@ -12,6 +12,7 @@ lastrun_file="$lastrun_dir/lastrun" mobile_docs="$HOME/doc/mobile" notes="$HOME/doc/notes" server_fqdn="nextcloud.djmoch.org" +rsync_flags="-qu" if [ -d "$lastrun_dir" ] then @@ -41,16 +42,13 @@ fi LOCAL_PHOTOS="$HOME/doc/pix" -# Mount the WebDAV folder and set so only we can read it -if mount /mnt/nextcloud +# Mount the folder +if doas /sbin/mount /mnt/nextcloud then - echo "NextCloud WebDAV successfully mounted. Setting permissions." - chmod 700 /mnt/nextcloud - # Rsync from WebDAV to ~/Photos - echo "Syncing Photos from WebDAV to $LOCAL_PHOTOS" + echo "Syncing Photos from NextCloud to $LOCAL_PHOTOS" [ ! -d $LOCAL_PHOTOS/$year/$month ] && mkdir -p $LOCAL_PHOTOS/$year/$month - rsync -aq /mnt/nextcloud/Photos/$year/$month/* $LOCAL_PHOTOS/$year/$month + rsync $rsync_flags /mnt/nextcloud/Photos/$year/$month/* $LOCAL_PHOTOS/$year/$month if [ -z "$firstrun" -a $lastrun_month -ne $month ] then # TODO: What if we're more than a month behind? @@ -58,13 +56,13 @@ then then mkdir -p $LOCAL_PHOTOS/$lastrun_year/$lastrun_month fi - rsync -aq /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month/* $LOCAL_PHOTOS/$lastrun_year/$lastrun_month + rsync $rsync_flags /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month/* $LOCAL_PHOTOS/$lastrun_year/$lastrun_month fi - # Rsync from ~/Photos to WebDAV - echo "Syncing Photos from $LOCAL_PHOTOS to WebDAV" + # Rsync from ~/Photos to NextCloud + echo "Syncing Photos from $LOCAL_PHOTOS to NextCloud" [ ! -d /mnt/nextcloud/Photos/$year/$month ] && mkdir -p /mnt/nextcloud/Photos/$year/$month - rsync -aq $LOCAL_PHOTOS/$year/$month/* /mnt/nextcloud/Photos/$year/$month + rsync $rsync_flags $LOCAL_PHOTOS/$year/$month/* /mnt/nextcloud/Photos/$year/$month if [ -z "$firstrun" -a $lastrun_month -ne $month ] then if [ ! -d /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month ] @@ -72,22 +70,22 @@ then mkdir -p /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month fi # TODO: What if we're more than a month behind? - rsync -aq $LOCAL_PHOTOS/$lastrun_year/$lastrun_month/* /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month + rsync $rsync_flags $LOCAL_PHOTOS/$lastrun_year/$lastrun_month/* /mnt/nextcloud/Photos/$lastrun_year/$lastrun_month fi - # Rsync from ~/Documents/Mobile to WebDAV - echo "Syncing mobile documents from $mobile_docs to WebDAV" - rsync -aq "$mobile_docs"/* /mnt/nextcloud/Documents + # Rsync from ~/Documents/Mobile to NextCloud + echo "Syncing mobile documents from $mobile_docs to NextCloud" + rsync $rsync_flags "$mobile_docs"/* /mnt/nextcloud/Documents - # Rsync from WebDAV to ~/Documents/Mobile - echo "Syncing mobile documents from WebDAV to $mobile_docs" - rsync -aq /mnt/nextcloud/Documents/* "$mobile_docs" + # Rsync from NextCloud to ~/Documents/Mobile + echo "Syncing mobile documents from NextCloud to $mobile_docs" + rsync $rsync_flags /mnt/nextcloud/Documents/* "$mobile_docs" # Finish by unmounting the WebDAV folder echo "Unmounting $server_fqdn" - umount /mnt/nextcloud + doas /sbin/umount /mnt/nextcloud else - echo "NextCloud WebDAV mount FAILED. Exiting." + echo "NextCloud mount FAILED. Exiting." exit -2 fi