Compare commits
No commits in common. "cbaa5cf408b6cb0d6787e53921d2b3add53303f6" and "7244206de57e7c8bd9641feb50c7d052749207a2" have entirely different histories.
cbaa5cf408
...
7244206de5
@ -1,49 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
# Usage: borg_partclone_backup.sh VGNAME LVNAME SNP_SZ SRV_HOST SRV_BORG_REPO
|
|
||||||
VGNAME=$1
|
|
||||||
LVNAME=$2
|
|
||||||
SNP_NM=$LVNAME-`date +%Y%m%dT%H%M%S`
|
|
||||||
SNP_SZ=$3
|
|
||||||
SRV_HOST=$4
|
|
||||||
SRV_BORG_REPO=$5
|
|
||||||
|
|
||||||
exitmsg () {
|
|
||||||
echo $1 >&2;
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
rmsnap () {
|
|
||||||
# Remove the snapshot
|
|
||||||
lvremove -y $VGNAME/$SNP_NM >/dev/null
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exitmsg_rm () {
|
|
||||||
rmsnap
|
|
||||||
exitmsg $1
|
|
||||||
}
|
|
||||||
|
|
||||||
exit_ok () {
|
|
||||||
rmsnap
|
|
||||||
echo "Successful backup for $VGNAME/$LVNAME"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
echo "Starting backup for $VGNAME/$LVNAME"
|
|
||||||
|
|
||||||
# Be root
|
|
||||||
test `id -u` == "0" || exitmsg "Run this script as root"
|
|
||||||
|
|
||||||
# Create the snapshot
|
|
||||||
lvcreate -y -n $SNP_NM -s -L $SNP_SZ $VGNAME/$LVNAME >/dev/null || exitmsg "Cannot create snapshot"
|
|
||||||
|
|
||||||
# Check filesystem
|
|
||||||
fsck -y /dev/$VGNAME/$SNP_NM || exitmsg_rm "Failed to check filesystem /dev/$VGNAME/$SNP_NM"
|
|
||||||
|
|
||||||
# Clone
|
|
||||||
partclone.ext4 -s /dev/$VGNAME/$SNP_NM -c -q >/dev/null 2>&1 | \
|
|
||||||
BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes \
|
|
||||||
borg2 -r ssh://$SRV_HOST$SRV_BORG_REPO create --stdin-name image.pcl $SNP_NM - || exitmsg_rm "Backup failed for $SNP_NM"
|
|
||||||
|
|
||||||
exit_ok
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
# Usage: borg_partclone_backup.sh VGNAME LVNAME SNP_SZ PART_NO SRV_HOST SRV_BORG_REPO
|
|
||||||
VGNAME=$1
|
|
||||||
LVNAME=$2
|
|
||||||
DATE=`date +%Y%m%dT%H%M%S`
|
|
||||||
SNP_NM=$LVNAME-$DATE
|
|
||||||
SNP_SZ=$3
|
|
||||||
PART_NO=$4
|
|
||||||
SRV_HOST=$5
|
|
||||||
SRV_BORG_REPO=$6
|
|
||||||
SRV_BORG_BACKUP_NAME=$LVNAME-$7-$DATE
|
|
||||||
|
|
||||||
exitmsg () {
|
|
||||||
echo $1
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
rmsnap () {
|
|
||||||
# Remove the snapshot
|
|
||||||
lvremove -y $VGNAME/$SNP_NM >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
rmloop () {
|
|
||||||
# Free the loop device
|
|
||||||
losetup -D /dev/loop0 >/dev/null
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exitmsg_rm () {
|
|
||||||
rmsnap
|
|
||||||
exitmsg $1
|
|
||||||
}
|
|
||||||
|
|
||||||
exitmsg_rm_loop () {
|
|
||||||
rmloop
|
|
||||||
exitmsg_rm $1
|
|
||||||
}
|
|
||||||
|
|
||||||
exit_ok () {
|
|
||||||
rmloop
|
|
||||||
rmsnap
|
|
||||||
echo "Successful backup for $VGNAME/$LVNAME part. $PART_NO"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
echo "Starting backup for $VGNAME/$LVNAME part. $PART_NO"
|
|
||||||
|
|
||||||
# Be root
|
|
||||||
test `id -u` == "0" || exitmsg "Run this script as root"
|
|
||||||
|
|
||||||
# Create the snapshot
|
|
||||||
lvcreate -y -n $SNP_NM -s -L $SNP_SZ $VGNAME/$LVNAME >/dev/null || exitmsg "Cannot create snapshot"
|
|
||||||
|
|
||||||
# Setup loopback device
|
|
||||||
losetup -P /dev/loop0 /dev/$VGNAME/$SNP_NM || exitmsg_rm "/dev/loop0 already used"
|
|
||||||
|
|
||||||
# Check filesystem
|
|
||||||
fsck -y /dev/loop0p$PART_NO || exitmsg_rm_loop "Failed to check filesystem /dev/loop0p$PART_NO"
|
|
||||||
|
|
||||||
# Clone
|
|
||||||
partclone.ext4 -s /dev/loop0p$PART_NO -c -q 2>&1 | \
|
|
||||||
BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes \
|
|
||||||
borg2 -r ssh://$SRV_HOST$SRV_BORG_REPO create --stdin-name image.pcl $SRV_BORG_BACKUP_NAME - || exitmsg_rm_loop "Backup failed for $VGNAME/$SNP_NM part. $PART_NO"
|
|
||||||
|
|
||||||
exit_ok
|
|
||||||
@ -1,55 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from configparser import ConfigParser
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
def get_fingerprint(url):
|
|
||||||
return subprocess.run(['ssl_get_fingerprint.sh', url],
|
|
||||||
capture_output=True).stdout.decode().strip()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
cp = ConfigParser()
|
|
||||||
|
|
||||||
conf_file = os.path.join(
|
|
||||||
os.environ.get('HOME'),
|
|
||||||
'.config',
|
|
||||||
'vdirsyncer',
|
|
||||||
'config'
|
|
||||||
)
|
|
||||||
|
|
||||||
cp.read(conf_file)
|
|
||||||
|
|
||||||
storage_flt = lambda x: x.split(' ').pop(0) == 'storage'
|
|
||||||
|
|
||||||
urls_sects = {}
|
|
||||||
|
|
||||||
for sect in filter(storage_flt, cp.sections()):
|
|
||||||
if 'url' not in cp[sect]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
url = urlparse(eval(cp[sect]['url']))
|
|
||||||
if url.scheme != 'https':
|
|
||||||
continue
|
|
||||||
|
|
||||||
if url.netloc not in urls_sects:
|
|
||||||
urls_sects[url.netloc] = set()
|
|
||||||
|
|
||||||
urls_sects[url.netloc].add(sect)
|
|
||||||
|
|
||||||
for url in urls_sects.keys():
|
|
||||||
|
|
||||||
fp = get_fingerprint(url)
|
|
||||||
for sect in urls_sects[url]:
|
|
||||||
cp.set(sect, 'verify_fingerprint', f'"{fp}"')
|
|
||||||
|
|
||||||
with open(conf_file, 'w') as fh:
|
|
||||||
cp.write(fh)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
Loading…
Reference in New Issue
Block a user