sshfs map user, rsync backup with remote option

This commit is contained in:
Ville Rantanen
2022-10-04 18:45:30 +03:00
parent c377431c1a
commit 4344303e7c
2 changed files with 16 additions and 1 deletions

View File

@@ -8,13 +8,14 @@ import shlex
import json
from argparse import ArgumentParser
VERSION = "1.2"
VERSION = "1.3"
class RSB:
def __init__(self, options):
self.options = options
self.lock = options.lock
self.no_backup = options.no_backup
self.base_folder = options.base_folder
self.backup_source = options.backup_source
self.rsync_args = options.rsync_args
@@ -105,6 +106,10 @@ class RSB:
subprocess.call(["cp", "-la", self.current, tgt_dir], shell=False)
def make_backup(self):
if self.options.no_backup:
print("Not making backup, as requested")
return True
print("Backing up")
command = [
"rsync",
@@ -202,7 +207,15 @@ def get_opts():
default=False,
help="Use locking to prevent concurrent backups",
)
parser.add_argument(
"--no-backup",
dest="no_backup",
action="store_true",
default=False,
help="Do not rsync for backup, only create hardlinks, and clean up. Use this when backuping to a remote machine, and run it at the remote matchine. Example: rsync -a --del ~/ remote:backups/home/current/; ssh remote rsync-backup --no-backup ~/ backups/home/",
)
parser.add_argument("--version", action="version", version=VERSION)
parser.add_argument(
"backup_source", action="store", help="Source URL to backup with rsync"
)

View File

@@ -93,6 +93,8 @@ if [[ $device1 = $device2 ]]; then
eval sshfs \
-o reconnect \
-o uid=`id -u` \
-o gid=`id -g` \
-o ServerAliveInterval=45,ServerAliveCountMax=2 \
$NOSAVE \
-o follow_symlinks "$valid_name$path" "$valid_name"