Rsync examples

#TrueNAS
sleep 5
rsync -avxzzhSP –stats –delete –rsh=ssh /mnt/owncloud-data root@truenas.domain.tld:/mnt/tank0/backup/

sleep 5
ssh root@truenas.domain.tld chown -R user:user /mnt/tank0/backup/

#Linux
sleep 5
rsync -avxzhSP –stats –delete –rsh=ssh /mnt/owncloud-data root@linux-server.domain.tld:/mnt/backup/

#Google Drive
# Prereqs see https://www.more-it.de/mount-google-drive-locally-to-a-linux-machine/
sleep 5
rsync -avxzh –progress –stats –inplace –delete /mnt/owncloud-data/ /mnt/google-drive/

Mount Google Drive locally to a Linux machine

Install everything to mount the Google Drive to a local folder in Linux
Source: https://github.com/astrada/google-drive-ocamlfuse
sudo add-apt-repository ppa:alessandro-strada/ppa
sudo apt-get update
sudo apt-get install google-drive-ocamlfuse

Configure Google Drive API and OAuth consent screen headless
Source: https://github.com/astrada/google-drive-ocamlfuse/wiki/Headless-Usage-&-Authorization

Sign in to your Google account and create a project: https://console.cloud.google.com/

Enable the Google Drive API
In the left-hand pane (Navigation menu), open „APIs & Services“ -> „Library“, this will take you to https://console.cloud.google.com/apis/library
Click on „Google Drive API“, this will open https://console.cloud.google.com/apis/library/drive.googleapis.com . Click „ENABLE API“.

Get your client ID and client secret
Open the Navigation menu (click the hamburger icon at the top left), open „APIs & Services“ -> „Credentials“, this will open https://console.cloud.google.com/apis/credentials
Then click on the button „Create Credentials“, and choose choose „OAuth client ID“, this will take you to https://console.cloud.google.com/apis/credentials/oauthclient .
For Application type, choose „Other“ or „Desktop“
For Name, input something personal, for example „My OCAMLDrive“.
Click „Create“. You will get a Client ID, a Client Secret.

If you have no Workspace and just a personal Google account please add the accounts mail address to testusers of the OAuth Consent Screen

Issue command
google-drive-ocamlfuse -headless -id 212334322535-dniangkjndforanbiurnbiuuan.apps.googleusercontent.com -secret YTFUBKJN-quikdgsdnJ_BSfa8dsfjgJSBGdkj

Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=212334322535-dniangkjndforanbiurnbiuuan.apps.googleuserconte&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force

Please enter the verification code:
5/OJBKJB78yHB-kdjsfsds733q3dfsdf_dsdfsj4235234_G-dsgdfgds-2398u54kngfldshgf
Access token retrieved correctly.

If you have trouble accessing it after a few days and also remounting leads into io-error notification please delete ~/.gdfuse director and redo the above auth steps.

Create a image file, encrypt via LUKS and mount it and rsync to it from remote Linux

On remote side
sudo -i
dd if=/dev/zero of=/root/file-luks.container bs=4M count=25000 status=progress
mkdir -p /mnt/file-luks.mountpoint
apt install cryptsetup
modprobe dm-crypt
cryptsetup -y luksFormat ~/file-luks.container
cryptsetup open /root/file-luks.container file-luks
mkfs -t ext4 /dev/mapper/file-luks
mount /dev/mapper/file-luks /mnt/file-luks.mountpoint

On local side
cd source
rsync -avxzhSP –delete –rsh=ssh ./* root@remote-host.tld:/mnt/owncloud-luks.mountpoin