FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 71da2ff1 authored by Dr Adam Thorn's avatar Dr Adam Thorn
Browse files

Escape $ in ssh commands used in prepare scripts

Our backup logs are generally full of

+ ssh -p 22 -o ConnectTimeout=10 root@openvpn2020.ch.cam.ac.uk '
  umask 077
  FILELIST=`tempfile`
  CONFLIST=`tempfile`
  mkdir -p /var/adm/backup
  # Make logrotate use datestamps
  if ! grep -q dateext /etc/logrotate.conf ; then sed  -i '\''s/^include/dateext\ninclude/'\'' /etc/logrotate.conf ; fi
  # Which packages are installed?
  dpkg --get-selections | awk '\'' { print $1 ; } '\'' >/var/adm/backup/packages
  cat /var/lib/dpkg/info/*.list | while read F ; do [ -f "$F" ] && echo "$F" ; done | sort > $FILELIST
  awk '\''/Description:/ { flag = 0 } ; flag == 1 { print $1 ; }  ; /Conffiles:/ { flag = 1  } ; '\'' </var/lib/dpkg/status |  sort >$CONFLIST
  diff -u $FILELIST $CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
  rm
 '
rm: missing operand

because we're not escaping the args to that final rm command! This means we gradually fill
up /tmp, especially on machines that are infrequently rebooted (e.g. calculon)
parent ee9022a5
No related branches found
Tags 0.9-ch73
No related merge requests found
......@@ -3,7 +3,7 @@ Priority: optional
Section: otherosfs
Maintainer: Frank Lee <rl201@cam.ac.uk>
Architecture: all
Version: 0.9-ch55
Version: 0.9-ch56
Depends: zfs-dkms, postgresql-9.5 | postgresql-9.4 , liblockfile-simple-perl, libdbi-perl, libjson-perl, libzfs-perl-chem, libnet-openssh-perl, libdbd-pg-perl, mbuffer, rsync, nfs-kernel-server, pv, libwww-curl-perl
Description: a backup system using ZFS
Ported (well, mostly) from FreeBSD to a Sane OS.
......@@ -31,7 +31,7 @@ if $SSH root@$SERVER [ /var/lib/dpkg/status -nt /var/adm/backup/package-files ]
cat /var/lib/dpkg/info/*.list | while read F ; do [ -f \"\$F\" ] && echo \"\$F\" ; done | sort > \$FILELIST
awk '/Description:/ { flag = 0 } ; flag == 1 { print \$1 ; } ; /Conffiles:/ { flag = 1 } ; ' </var/lib/dpkg/status | sort >\$CONFLIST
diff -u \$FILELIST \$CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
rm $FILELIST $CONFLIST
rm \$FILELIST \$CONFLIST
"
mkdir -p $CONFDIR/$SERVER
$SCP -q root@$SERVER:/var/adm/backup/package-files $CONFDIR/$SERVER/exclude
......
......@@ -37,7 +37,7 @@ if $SSH root@$SERVER [ /var/lib/dpkg/status -nt /var/adm/backup/package-files ]
cat /var/lib/dpkg/info/*.list | while read F ; do [ -f \"\$F\" ] && echo \"\$F\" ; done | sort > \$FILELIST
awk '/Description:/ { flag = 0 } ; flag == 1 { print \$1 ; } ; /Conffiles:/ { flag = 1 } ; ' </var/lib/dpkg/status | sort >\$CONFLIST
diff -u \$FILELIST \$CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
rm $FILELIST $CONFLIST
rm \$FILELIST \$CONFLIST
"
mkdir -p $CONFDIR/$SERVER
$SCP -q root@$SERVER:/var/adm/backup/package-files $CONFDIR/$SERVER/exclude
......
......@@ -37,7 +37,7 @@ if $SSH root@$SERVER [ /var/lib/dpkg/status -nt /var/adm/backup/package-files ]
cat /var/lib/dpkg/info/*.list | while read F ; do [ -f \"\$F\" ] && echo \"\$F\" ; done | sort > \$FILELIST
awk '/Description:/ { flag = 0 } ; flag == 1 { print \$1 ; } ; /Conffiles:/ { flag = 1 } ; ' </var/lib/dpkg/status | sort >\$CONFLIST
diff -u \$FILELIST \$CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
rm $FILELIST $CONFLIST
rm \$FILELIST \$CONFLIST
"
mkdir -p $CONFDIR/$SERVER
$SCP -q root@$SERVER:/var/adm/backup/package-files $CONFDIR/$SERVER/exclude
......
......@@ -27,6 +27,7 @@ if $SSH root@$SERVER [ /var/lib/dpkg/status -nt /var/adm/backup/package-files ]
cat /var/lib/dpkg/info/*.list | while read F ; do [ -f \"\$F\" ] && echo \"\$F\" ; done | sort > \$FILELIST
awk '/Description:/ { flag = 0 } ; flag == 1 { print \$1 ; } ; /Conffiles:/ { flag = 1 } ; ' </var/lib/dpkg/status | sort >\$CONFLIST
diff -u \$FILELIST \$CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
rm \$FILELIST \$CONFLIST
"
mkdir -p /etc/chem-zfs-backup-server/zfs-rsync.d/$SERVER
scp -q root@$SERVER:/var/adm/backup/package-files /etc/chem-zfs-backup-server/zfs-rsync.d/$SERVER/exclude
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment