diff --git a/FreeBSD/jail-backup.csh b/FreeBSD/jail-backup.csh new file mode 100644 index 0000000..15af5fe --- /dev/null +++ b/FreeBSD/jail-backup.csh @@ -0,0 +1,41 @@ +#!/bin/csh + +## config section +set ezjail_config_dir = "/usr/local/etc/ezjail" +set backup_config_dir = "/tank/backup/jails" +set backup_date = `date "+%Y%m%d%H%M.%S"` + +# backup all jails +echo "" +echo "################ BACKUP JAILS #################" +foreach jail (`ls /usr/jails | \ + grep -v basejail | \ + grep -v ezjail_archives | \ + grep -v flavours | \ + grep -v newjail | \ + grep -v fulljail`) + + ## stopping jail + ezjail-admin stop $jail + + ## start backing up jail + jailconfig + echo "Backup jails: $jail" + + ## backup jail config + cp $ezjail_config_dir/$jail $backup_config_dir + mv $backup_config_dir/$jail "$backup_config_dir/$jail-$backup_date.conf" + + ## backup jail content + ezjail-admin archive $jail + echo "" + + ## start jail + ezjail-admin start $jail + echo "" + +end + +# report done +echo "" +echo "############### ALL DONE THANKS ###############" +echo "" diff --git a/FreeBSD/jail-update.csh b/FreeBSD/jail-update.csh new file mode 100644 index 0000000..7a978ed --- /dev/null +++ b/FreeBSD/jail-update.csh @@ -0,0 +1,32 @@ +#!/bin/csh + +# Upgrade host packages +echo "" +echo "############ UPGRADE HOST PACKAGES ############" +echo "" +pkg update && \ +pkg upgrade -y && \ +pkg clean -ya + +# Upgrade jail packages +echo "" +echo "############ UPGRADE JAIL PACKAGES ############" +foreach jail (`ls /usr/jails | \ + grep -v basejail | \ + grep -v ezjail_archives | \ + grep -v flavours | \ + grep -v newjail | \ + grep -v fulljail`) + + echo "" + echo "Updating $jail" + pkg -j $jail update && \ + pkg -j $jail upgrade -y && \ + pkg -j $jail clean -ay + +end + +# Report done +echo "" +echo "############### ALL DONE THANKS ###############" +echo ""