diff options
author | k0n24d | 2016-06-20 16:57:19 +0200 |
---|---|---|
committer | k0n24d | 2016-06-20 16:57:19 +0200 |
commit | 9f97eab5feb840f1a6c6aa77d5ca28578119ae4b (patch) | |
tree | a84340982b0effcc65cbed792edbc04a354c45cc | |
download | aur-9f97eab5feb840f1a6c6aa77d5ca28578119ae4b.tar.gz |
Initial version
-rw-r--r-- | .SRCINFO | 39 | ||||
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | PKGBUILD | 58 | ||||
-rw-r--r-- | btrfs_create_filesystem_snapshot | 33 | ||||
-rw-r--r-- | btrfs_remove_filesystem_snapshot | 35 | ||||
-rw-r--r-- | dattobd_create_filesystem_snapshot | 87 | ||||
-rw-r--r-- | dattobd_remove_filesystem_snapshot | 74 | ||||
-rw-r--r-- | defaults_client | 40 | ||||
-rw-r--r-- | lvm_create_filesystem_snapshot | 67 | ||||
-rw-r--r-- | lvm_remove_filesystem_snapshot | 56 |
10 files changed, 494 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..7abae734757c --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,39 @@ +pkgbase = urbackup2-client-no-gui + pkgdesc = Client Server backup system + pkgver = 2.0.28 + pkgrel = 1 + url = http://www.urbackup.org/ + arch = i686 + arch = x86_64 + arch = armv5 + arch = armv6h + arch = armv6 + arch = armv7h + arch = armv7 + arch = aarch64 + license = GPL + makedepends = gcc-libs + makedepends = gcc + makedepends = make + depends = crypto++ + depends = zlib + conflicts = urbackup-client-no-gui + source = https://www.urbackup.org/downloads/Client/2.0.28/urbackup-client-2.0.28.0.tar.gz + source = btrfs_create_filesystem_snapshot + source = btrfs_remove_filesystem_snapshot + source = dattobd_create_filesystem_snapshot + source = dattobd_remove_filesystem_snapshot + source = defaults_client + source = lvm_create_filesystem_snapshot + source = lvm_remove_filesystem_snapshot + md5sums = 009fdbed706714c6946aef7a136df710 + md5sums = fcdef7852b3d847c5c2468a619e7fba9 + md5sums = b5f82ed45105f9929e9b98eee8b288fc + md5sums = 5a3c106ff05e9939902272c936b653eb + md5sums = b001546cc988ac8ea8646c9e1438316b + md5sums = b3442a7228cbb9ce56da85ba219ad925 + md5sums = e17da398a0d4074a3aae23c46d93db0b + md5sums = b8972631f9633b24b711bc831c972d42 + +pkgname = urbackup2-client-no-gui + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..e60d4d37acd5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +src +pkg +urbackup*.pkg.tar.xz +urbackup*.tar.gz +download diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..b39d8313ad9b --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,58 @@ +# Contributor: K0n24d <konrad AT knauber DOT net> +pkgname=urbackup2-client-no-gui +pkgver=2.0.28 +pkgrel=1 +pkgdesc="Client Server backup system" +arch=('i686' 'x86_64' 'armv5' 'armv6h' 'armv6' 'armv7h' 'armv7' 'aarch64') +url="http://www.urbackup.org/" +license=("GPL") +makedepends=('gcc-libs' 'gcc' 'make') +depends=('crypto++' 'zlib') +conflicts=('urbackup-client-no-gui') +source=("https://www.urbackup.org/downloads/Client/${pkgver}/urbackup-client-${pkgver}.0.tar.gz" + 'btrfs_create_filesystem_snapshot' + 'btrfs_remove_filesystem_snapshot' + 'dattobd_create_filesystem_snapshot' + 'dattobd_remove_filesystem_snapshot' + 'defaults_client' + 'lvm_create_filesystem_snapshot' + 'lvm_remove_filesystem_snapshot') + +md5sums=('009fdbed706714c6946aef7a136df710' + 'fcdef7852b3d847c5c2468a619e7fba9' + 'b5f82ed45105f9929e9b98eee8b288fc' + '5a3c106ff05e9939902272c936b653eb' + 'b001546cc988ac8ea8646c9e1438316b' + 'b3442a7228cbb9ce56da85ba219ad925' + 'e17da398a0d4074a3aae23c46d93db0b' + 'b8972631f9633b24b711bc831c972d42') + +CFLAGS="-march=native -O2 -pipe -fstack-protector-strong" +CXXFLAGS="${CFLAGS} -ansi" +MAKEFLAGS="-j$(nproc)" + +build() { + cd "${srcdir}/urbackup-client-${pkgver}.0" + ./configure --prefix=/usr --sbindir=/usr/bin --localstatedir=/var --sysconfdir=/etc --enable-headless + make +} + +package() { + cd "${srcdir}/urbackup-client-${pkgver}.0" + make DESTDIR="${pkgdir}" install + + install -Dm644 urbackupclientbackend-debian.service \ + "${pkgdir}"/usr/lib/systemd/system/urbackupclientbackend.service + install -Dm644 docs/urbackupclientbackend.1 \ + "${pkgdir}"/usr/share/man/man1/urbackupclientbackend.1 + + cd "${srcdir}" + install -Dm644 defaults_client "${pkgdir}/etc/default/urbackupclient" + install -Dm700 btrfs_create_filesystem_snapshot "${pkgdir}/usr/share/urbackup" + install -Dm700 btrfs_remove_filesystem_snapshot "${pkgdir}/usr/share/urbackup" + install -Dm700 lvm_create_filesystem_snapshot "${pkgdir}/usr/share/urbackup" + install -Dm700 lvm_remove_filesystem_snapshot "${pkgdir}/usr/share/urbackup" + install -Dm700 dattobd_create_filesystem_snapshot "${pkgdir}/usr/share/urbackup" + install -Dm700 dattobd_remove_filesystem_snapshot "${pkgdir}/usr/share/urbackup" +} +# vim: ts=2 diff --git a/btrfs_create_filesystem_snapshot b/btrfs_create_filesystem_snapshot new file mode 100644 index 000000000000..5d9375489af4 --- /dev/null +++ b/btrfs_create_filesystem_snapshot @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +mkdir -p /mnt/urbackup_snaps + +SNAP_ID=$1 +SNAP_MOUNTPOINT="$2" +SNAP_NAME="$3" +SNAP_ORIG_PATH="$4" +SNAP_DEST=/mnt/urbackup_snaps/$SNAP_ID + +TYPE=$(df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f2) + +if [[ $TYPE == "" ]] +then + if btrfs subvolume list -o "$SNAP_MOUNTPOINT" > /dev/null 2>&1 + then + TYPE="btrfs" + fi +fi + +if [[ $TYPE == "btrfs" ]] +then + btrfs subvolume snapshot -r "$SNAP_MOUNTPOINT" "$SNAP_DEST" +else + echo "Cannot create snapshot of file system with type $TYPE" + exit 1 +fi + +echo "SNAPSHOT=$SNAP_DEST" + +exit 0
\ No newline at end of file diff --git a/btrfs_remove_filesystem_snapshot b/btrfs_remove_filesystem_snapshot new file mode 100644 index 000000000000..e3377ca47439 --- /dev/null +++ b/btrfs_remove_filesystem_snapshot @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e + +SNAP_ID=$1 +SNAP_MOUNTPOINT="$2" +SNAP_NAME="$3" +SNAP_DEST="$4" +SNAP_ORIG_PATH="$5" + +if ! test -e $SNAP_MOUNTPOINT +then + echo "Snapshot at $SNAP_MOUNTPOINT was already removed" + exit 0 +fi + +TYPE=$(df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | tr -s " " | cut -d" " -f2) + +if [[ $TYPE == "" ]] +then + if btrfs subvolume list -o "$SNAP_MOUNTPOINT" > /dev/null 2>&1 + then + TYPE="btrfs" + fi +fi + +if [[ $TYPE == "btrfs" ]] +then + btrfs subvolume delete "$SNAP_MOUNTPOINT" +else + echo "Cannot remove snapshot at $SNAP_MOUNTPOINT. File system type $TYPE not supported." + exit 1 +fi + +exit 0
\ No newline at end of file diff --git a/dattobd_create_filesystem_snapshot b/dattobd_create_filesystem_snapshot new file mode 100644 index 000000000000..c4faa3612ddf --- /dev/null +++ b/dattobd_create_filesystem_snapshot @@ -0,0 +1,87 @@ +#!/bin/sh + +set -e + +mkdir -p /mnt/urbackup_snaps + +SNAP_ID=$1 +SNAP_MOUNTPOINT="$2" +SNAP_DEST=/mnt/urbackup_snaps/$SNAP_ID + +DEVICE=$(df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f1) +TYPE=$(df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f2) + +if [ "x$DEVICE" = "x" ] +then + echo "Cannot get device for filesystem $SNAP_MOUNTPOINT" + exit 1 +fi + +echo "Snapshotting device $DEVICE via dattobd..." + +NUM=0 + +while [ -e "/dev/datto$NUM" ] +do + NUM=`expr $NUM + 1` +done + +if ! modprobe dattobd +then + echo "Dattobd kernel module not available" + exit 1 +fi + +echo "Using /dev/datto$NUM..." + +sync + +dbdctl setup-snapshot "$DEVICE" "$SNAP_MOUNTPOINT/.datto_$SNAP_ID" $NUM + +echo $NUM > ${SNAP_DEST}-num + +DEV_SIZE=`blockdev --getsize /dev/datto$NUM` + +truncate -s100M $SNAP_MOUNTPOINT/.overlay_$SNAP_ID + +LODEV=`losetup -f` + +if [ "x$LODEV" = x ] +then + rm "${SNAP_DEST}-num" + rm $SNAP_MOUNTPOINT/.overlay_$SNAP_ID + dbdctl destroy $NUM + exit 1 +fi + + +losetup $LODEV $SNAP_MOUNTPOINT/.overlay_$SNAP_ID + +echo "0 $DEV_SIZE snapshot /dev/datto$NUM $LODEV N 8" | dmsetup create "wsnap-$SNAP_ID" + +echo "Mounting /dev/mapper/wsnap-$SNAP_ID..." + +mkdir -p $SNAP_DEST + +MOUNTOPTS="ro" + +if [ $TYPE = "xfs" ] +then + MOUNTOPTS="ro,nouuid" +fi + +if ! mount -o $MOUNTOPTS /dev/mapper/wsnap-$SNAP_ID $SNAP_DEST +then + echo "Mounting filesystem failed" + rmdir "$SNAP_DEST" + rm "${SNAP_DEST}-num" + dmsetup remove "wsnap-$SNAP_ID" + losetup -d $LODEV + rm $SNAP_MOUNTPOINT/.overlay_$SNAP_ID + dbdctl destroy $NUM + exit 1 +fi + +echo "SNAPSHOT=$SNAP_DEST" + +exit 0
\ No newline at end of file diff --git a/dattobd_remove_filesystem_snapshot b/dattobd_remove_filesystem_snapshot new file mode 100644 index 000000000000..16c9a63f0529 --- /dev/null +++ b/dattobd_remove_filesystem_snapshot @@ -0,0 +1,74 @@ +#!/bin/sh + +set -e + +SNAP_ID=$1 +SNAP_MOUNTPOINT="$2" +SNAP_ORIG_PATH="$5" + +remove_overlay() { + if test -e "$SNAP_ORIG_PATH/.overlay_$SNAP_ID" + then + LODEV=`losetup -j "$SNAP_ORIG_PATH/.overlay_$SNAP_ID" | cut -d':' -f1` + if [ "x$LODEV" != x ] + then + losetup -d $LODEV + fi + rm "$SNAP_ORIG_PATH/.overlay_$SNAP_ID" + fi +} + +if ! test -e $SNAP_MOUNTPOINT +then + echo "Snapshot at $SNAP_MOUNTPOINT was already removed" + [ ! -e "$SNAP_ORIG_PATH/.datto_$SNAP_ID" ] || rm "$SNAP_ORIG_PATH/.datto_$SNAP_ID" + [ ! -e "${SNAP_MOUNTPOINT}-num" ] || rm "${SNAP_MOUNTPOINT}-num" + remove_overlay + exit 0 +fi + +if ! df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" > /dev/null 2>&1 +then + echo "Snapshot is not mounted. Already removed" + rm "${SNAP_MOUNTPOINT}-num" + rmdir "${SNAP_MOUNTPOINT}" + [ ! -e "$SNAP_ORIG_PATH/.datto_$SNAP_ID" ] || rm "$SNAP_ORIG_PATH/.datto_$SNAP_ID" + remove_overlay + exit 0 +fi + +NUM=`cat "${SNAP_MOUNTPOINT}-num"` || true + +if [ "x$NUM" = "x" ] +then + echo "Cannot get device number from ${SNAP_MOUNTPOINT}-num" + exit 1 +fi + +echo "Unmounting /dev/datto$NUM at /mnt/urbackup_snaps/$SNAP_ID..." + +if ! umount /mnt/urbackup_snaps/$SNAP_ID +then + lsof | grep /mnt/urbackup_snaps/$SNAP_ID || true + echo "Unmounting /mnt/urbackup_snaps/$SNAP_ID failed. Retrying in 10s..." + sleep 10 + umount /mnt/urbackup_snaps/$SNAP_ID +fi + + +rm "${SNAP_MOUNTPOINT}-num" +rmdir "${SNAP_MOUNTPOINT}" + +echo "Removing devicemapper snapshot..." + +dmsetup remove "wsnap-$SNAP_ID" + +remove_overlay + +echo "Destroying dattobd snapshot /dev/datto$NUM..." + +dbdctl destroy $NUM + +[ ! -e "$SNAP_ORIG_PATH/.datto_$SNAP_ID" ] || rm "$SNAP_ORIG_PATH/.datto_$SNAP_ID" + +exit 0
\ No newline at end of file diff --git a/defaults_client b/defaults_client new file mode 100644 index 000000000000..2e4b108d9a99 --- /dev/null +++ b/defaults_client @@ -0,0 +1,40 @@ +# Defaults for urbackup_client initscript +# sourced by /etc/init.d/urbackupclientbackend +# installed at /etc/default/urbackupclient by the maintainer scripts + +# +# This is parsed as a key=value file +# + +#logfile name +LOGFILE="/var/log/urbackupclient.log" + +#Either debug,warn,info or error +LOGLEVEL=warn + +#Max size of the log file before rotation +#Disable if you are using logrotate for +#more advanced configurations (e.g. with compression) +LOG_ROTATE_FILESIZE=20971520 + +#Max number of log files during rotation +LOG_ROTATE_NUM=10 + +#Tmp file directory +DAEMON_TMPDIR="/tmp" + +# Valid settings: +# +# "client-confirms": If you have the GUI component the currently active user +# will need to confirm restores from the web interface. +# If you have no GUI component this will cause restores +# from the server web interface to not work +# "server-confirms": The server will ask the user starting the restore on +# the web interface for confirmation +# "disabled": Restores via web interface are disabled. +# Restores via urbackupclientctl still work +# +RESTORE=disabled + +#If true client will not bind to any external network ports (either true or false) +INTERNET_ONLY=false diff --git a/lvm_create_filesystem_snapshot b/lvm_create_filesystem_snapshot new file mode 100644 index 000000000000..3c919743f726 --- /dev/null +++ b/lvm_create_filesystem_snapshot @@ -0,0 +1,67 @@ +#!/bin/sh + +set -e + +#For 20GB +#SNAP_SIZE="-L20G" +SNAP_SIZE="-l50%FREE" + +mkdir -p /mnt/urbackup_snaps + +SNAP_ID=$1 +SNAP_MOUNTPOINT="$2" +SNAP_DEST=/mnt/urbackup_snaps/$SNAP_ID + +if lsblk -r --output "NAME,MOUNTPOINT" --paths > /dev/null 2>&1 +then + VOLNAME=`lsblk -r --output "NAME,MOUNTPOINT" --paths | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f1` +else + VOLNAME=`lsblk -r --output "NAME,MOUNTPOINT" | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f1` + VOLNAME="/dev/mapper/$VOLNAME" +fi + +TYPE=`df -T -P | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f2` + +if [ "x$VOLNAME" = x ] +then + echo "Could not find LVM volume for mountpoint ${SNAP_MOUNTPOINT}" + exit 1 +fi + +export LVM_SUPPRESS_FD_WARNINGS=1 + +VGNAME=`lvdisplay "$VOLNAME" | grep "VG Name" | tr -s " " | cut -d" " -f4` +if [ "x$VGNAME" = x ] +then + echo "Could not find LVM volume group of volume $VOLNAME" + exit 1 +fi + +if [ "x$SNAP_ID" = x ] +then + echo "No snapshot id specified" + exit 1 +fi + +lvcreate $SNAP_SIZE -s -n urbackup_snap_$SNAP_ID "$VOLNAME" + +mkdir -p /mnt/urbackup_snaps/$SNAP_ID + +MOUNTOPTS="ro" + +if [ $TYPE = "xfs" ] +then + MOUNTOPTS="ro,nouuid" +fi + +if ! mount -o $MOUNTOPTS /dev/$VGNAME/urbackup_snap_$SNAP_ID /mnt/urbackup_snaps/$SNAP_ID +then + echo "Mounting filesystem failed" + rmdir /mnt/urbackup_snaps/$SNAP_ID + lvremove -f /dev/$VGNAME/urbackup_snap_$SNAP_ID + exit 1 +fi + +echo "SNAPSHOT=/mnt/urbackup_snaps/$SNAP_ID" + +exit 0
\ No newline at end of file diff --git a/lvm_remove_filesystem_snapshot b/lvm_remove_filesystem_snapshot new file mode 100644 index 000000000000..e46c927607df --- /dev/null +++ b/lvm_remove_filesystem_snapshot @@ -0,0 +1,56 @@ +#!/bin/sh + +set -e + +SNAP_ID=$1 +SNAP_MOUNTPOINT="$2" + +if ! test -e $SNAP_MOUNTPOINT +then + echo "Snapshot at $SNAP_MOUNTPOINT was already removed" + exit 0 +fi + +if ! df -T -P | egrep "${SNAP_MOUNTPOINT}\$" > /dev/null 2>&1 +then + echo "Snapshot is not mounted. Already removed" + rmdir "${SNAP_MOUNTPOINT}" + exit 0 +fi + +if lsblk -r --output "NAME,MOUNTPOINT" --paths > /dev/null 2>&1 +then + VOLNAME=`lsblk -r --output "NAME,MOUNTPOINT" --paths | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f1` +else + VOLNAME=`lsblk -r --output "NAME,MOUNTPOINT" | egrep " ${SNAP_MOUNTPOINT}\$" | head -n 1 | tr -s " " | cut -d" " -f1` + VOLNAME="/dev/mapper/$VOLNAME" +fi + +if [ "x$VOLNAME" = x ] +then + echo "Could not find LVM volume for mountpoint ${SNAP_MOUNTPOINT}" + exit 1 +fi + +if [ ! -e "$VOLNAME" ] +then + echo "LVM volume for mountpoint ${SNAP_MOUNTPOINT} does not exist" + exit 1 +fi + +echo "Unmounting $VOLNAME at /mnt/urbackup_snaps/$SNAP_ID..." + +if ! umount /mnt/urbackup_snaps/$SNAP_ID +then + lsof | grep /mnt/urbackup_snaps/$SNAP_ID || true + sleep 10 + umount /mnt/urbackup_snaps/$SNAP_ID +fi + +rmdir "${SNAP_MOUNTPOINT}" + +echo "Destroying LVM snapshot $VOLNAME..." + +export LVM_SUPPRESS_FD_WARNINGS=1 + +lvremove -f "$VOLNAME" |