[CentOS] xen backup script

Tim Dunphy bluethundr at gmail.com
Mon Oct 18 00:08:52 EDT 2010


hello,


 I have a couple of longish commands that I run to backup my network
of xen hosts. I would like to cron this, but am having trouble issuing
the same command the second time to the second xen host:

 [root at LCENT01 ~]# ssh sum2 'for i in `virsh list | grep -v -e Id -e
--- -e "Domain-0"| awk '{print \$1}'`; do echo "shutting down $i";
sleep 2; virsh shutdown $i; sleep 2; echo "domain $i is shutdown";
echo echo; done'
root at sum2's password:
awk: cmd. line:1: {print
awk: cmd. line:1:       ^ unexpected newline or end of string


------

this is the script so far:

#!/bin/bash

for i in `virsh list | grep -v -e Id -e --- -e "Domain-0"| awk '{print
$1}'`; do echo "shutting down $i"; sleep 2; virsh shutdown $i; sleep
2; echo "domain $i is shutdown"; echo; echo; \


for i in *; do echo "copying $i to nas"; sleep 2; rsync -avzp
/mnt/store/xen/$i /mnt/nas/xen; sleep 2; echo "$i has been copied to
nas"; echo; echo; done

ssh sum2 'for i in `virsh list | grep -v -e Id -e --- -e "Domain-0"|
awk '{print \$1}'`; do echo "shutting down $i"; sleep 2; virsh
shutdown $i; sleep 2; echo "domain $i is shutdown"; echo echo; done'


I think this could actually pretty useful for folks. feel free to use
and improve I would appreciate the feedback to get this to work so I
don't have to run two separate jobs on separate hosts

thanks!!!




-- 
Here's my RSA Public key:
gpg --keyserver pgp.mit.edu --recv-keys 5A4873A9

Share and enjoy!!


More information about the CentOS mailing list