diff --git a/OneDriveBk b/OneDriveBk deleted file mode 100644 index 506b912..0000000 --- a/OneDriveBk +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -# For backing up files with OneDrive -# Assumes that the backup target is set up as OneDrive in rclone - -if [ $(id -u) -eq 0 ]; then - exec sudo -H -u sintan $0 "$@" -fi - -notify() { - #Detect the name of the display in use - local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)" - - #Detect the user using such display - local user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1) - - #Detect the id of the user - local uid=$(id -u $user) - - sudo -u $user DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send -a rclone -h string:desktop-entry:alacritty "$@" -} - -notify "OneDriveBk" "Backup started..." -flock -n /tmp/onedrivesync.lock rclone sync -c -L --log-file="/home/sintan/TempStorage/OneDriveBk.log" --log-level INFO "/home/sintan/TempStorage/OneDrive/" OneDrive:Backup -notify "OneDriveBk" "Backup finished!" - diff --git a/OneDriveBk.sh b/OneDriveBk.sh new file mode 100644 index 0000000..a03c6fa --- /dev/null +++ b/OneDriveBk.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# For backing up files with OneDrive, from my server. +# Assumes that the backup target is set up as encrypted-onedrive in rclone. +# I usually run it once a week by a cronjob. + +# force script to run as specific user +if [ "$(id -u)" -eq 0 ]; then + exec sudo -H -u sintan $0 "$@" +fi + +# Exit the whole script when ctrl+c is pressed +set -e + +# Run only one instance of this script at one time +[ "${BKLOCKER}" != "running" ] && exec env BKLOCKER="running" flock -en "/tmp/onedrivebk.lock" "$0" "$@" || : + +# List of backups + +rclone -v --fast-list --size-only --links --bwlimit 4M sync "/home/sintan/Pictures" encrypted-onedrive:"Pictures" + +rclone -v --fast-list --size-only --links --bwlimit 4M sync "/home/sintan/Videos" encrypted-onedrive:"Videos" + +rclone -v --fast-list --size-only --links --bwlimit 4M sync "/home/sintan/Academics" encrypted-onedrive:"Academics" + +rclone -v --fast-list --size-only --links --bwlimit 4M sync "/home/sintan/Zotero" encrypted-onedrive:"Zotero" + +rclone -v --fast-list --size-only --links --bwlimit 4M sync "/mnt/storage/Music" encrypted-onedrive:"Music" + +rclone -v --fast-list --size-only --links --bwlimit 4M sync --exclude="**/.stversions/**" --exclude="/CalibreLibrary/**"\ + "/mnt/storage/Documents" encrypted-onedrive:"Documents" + +rclone -v --fast-list --size-only --links --exclude="**/menus/**" --exclude="**/unity3d/**"\ + --exclude="**/libreoffice/**" --ignore-errors --bwlimit 4M sync "/mnt/storage/dotfiles" encrypted-onedrive:"dotfiles" + +rclone -v --fast-list --size-only --links --bwlimit 4M --exclude="**/.stfolders/**"\ + --exclude="**/.trashed**" --delete-excluded sync "/home/sintan/TempStorage/DCIM" encrypted-onedrive:"DCIM" + +rclone -v --fast-list --size-only --links --bwlimit 4M --exclude="*-config/**" sync "/mnt/storage/Programs"\ + encrypted-onedrive:"Programs" +