Skip to content

Instantly share code, notes, and snippets.

@mariuszmikolajczak
Created January 23, 2022 13:29
Show Gist options
  • Save mariuszmikolajczak/81339d73ba10069cea1f8f775cd45a52 to your computer and use it in GitHub Desktop.
Save mariuszmikolajczak/81339d73ba10069cea1f8f775cd45a52 to your computer and use it in GitHub Desktop.
#!/bin/bash
source_dir="/var/lib/unifi/backup/autobackup/"
share_name="unifi-backups"
share_dest="/mnt/$share_name"
smb_ip=""
smb_user="unifi"
smb_password=""
isMounted () { findmnt "$1" >/dev/null;}
mkdir -p $share_dest
if ! isMounted "$share_dest"; then
mount -t cifs -o username=$smb_user,password=$smb_password //$smb_ip/$share_name $share_dest
fi
if isMounted "$share_dest"; then
rsync -a $source_dir $share_dest
umount $share_dest
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment