Automate.sh howto

ZorOS live CD menu shows an entry named "Automate": this open a procedure that search across network the script "automate.sh". Inside this file we can put anything as code, but the script is designed primarily to automate the backup and restore of operating systems. Here some examples:

automate-make-image.sh - make image of partition

#!/bin/sh
 
#-----------------------------------------------------------------------
echoc "Automate: automatic administration of the system" blue
#-----------------------------------------------------------------------
 
# Note:
# 1) in local network must be present a Server with DHCP service and a shared folder
# named "SHARE" (Win or Samba with read/write access)
# 2) in this example we assume to make image of a WinXP installation on NTFS filesystem
# from first partition of first IDE disk
 
echoc "Saving image of WinXP partition" yellow
 
sleep 2
 
partimage -g 0 -z1 -o -c -d save /dev/sda1 /net/pc01-XP-img


automate-restore.sh - restore image of partition

#!/bin/sh
 
#-----------------------------------------------------------------------
echoc "Automate: automatic administration of the system" blue
#-----------------------------------------------------------------------
 
# Note:
# 1) in local network must be present a Server with DHCP service and a shared folder
# named "SHARE" (Win or Samba with read access)
# 2) in this example we assume to restore a WinXP image in first partition
 
 
#------------- restore image ----------------------
 
 
echoc "Restore image of WinXP" yellow
 
sleep 2
 
partimage -g 0 -b restore /dev/sda1 /net/pc01-XP-img


automate-multiple-restore.sh - restore MBR and track 0, restore 2 images in 2 different partitions

#!/bin/sh
 
#-----------------------------------------------------------------------
echoc "Automate: automatic administration of the system" blue
#-----------------------------------------------------------------------
 
# Note:
# 1) in local network must be present a Server with DHCP service and a shared folder
# named "SHARE" (Win or Samba with read access)
# 2) in this example we assume to restore multiple images of a WinXP (first partition)
# and W2000 (second partition)
 
 
#------------- wait user confirm ---------------
echoc "WARNING: this procedure restore partitions 1 and 2" red
echoc "all data in partitions will be lost ..." red
echo -n "type 'okay' to proceed : "
 
read KEY_
 
if [ "a$KEY_" != "aokay" ] ; then
 echo "break by user ..."
 exit
fi
 
#------------- restore track 0 (partitions and boot manager)
 
echoc "Restore track 0" green
dd if=/net/track0-pcsample.bin of=/dev/sda
 
echoc "Re-syncing partition table in kernel" green
sfdisk -R /dev/sda
 
sleep 2
 
#------------- restore XP ----------------------
 
echoc "Restore XP" yellow
 
partimage -g 0 -b restore /dev/sda1 /net/XP-pcsample.000
 
sleep 2
 
#------------- restore W2000 ----------------------
 
echoc "Restore W2000" yellow
 
partimage -g 0 -b restore /dev/sda2 /net/W2000-pcsample.000

Note: we assumes a previous backup of track 0 in a file

dd if=/dev/sda of=/net/track0-pcsample.bin count=63
Retrieved from "http://www.zoros.org/wiki/index.php?title=Automate_script_examples_using_zoros_live_tools"