mirror of
https://github.com/SinTan1729/random.git
synced 2025-04-11 05:36:04 -05:00
chg: OneDriveBk
This commit is contained in:
parent
5c3febc5c0
commit
f1eec7186a
2 changed files with 41 additions and 26 deletions
26
OneDriveBk
26
OneDriveBk
|
@ -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!"
|
||||
|
41
OneDriveBk.sh
Normal file
41
OneDriveBk.sh
Normal file
|
@ -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"
|
||||
|
Loading…
Reference in a new issue