/
Offline vdisk files backup script example

Offline vdisk files backup script example

Description

The following script, executed in root's crontab, is an example of offline vdisk files bakups. The steps are:

Script

/charon/charon_backup_pluto
#!/bin/bash
WASACT=`systemctl is-active charon_pluto 2>/dev/null`

if test "${WASACT}" = "active"
then
  echo "`date +'%Y%m%d:%H%M%S'` Stopping charon_pluto service"
  systemctl stop  charon_pluto

  while test 1
  do
    echo "`date +'%Y%m%d:%H%M%S'` Waiting 60 seconds for full stop..."
    sleep 60
    systemctl -q is-active charon_pluto
    test $? -eq 3 && break
  done
fi

echo "`date +'%Y%m%d:%H%M%S'` Service status:"
systemctl -l status charon_pluto

echo "`date +'%Y%m%d:%H%M%S'` Zipping /charon/disks/pluto_tru64.vdisk file"
zip -j /charon/backups/pluto_tru64.vdisk.`date +%a`.zip /charon/disks/pluto_tru64.vdisk
RET=$?

if test "${WASACT}" = "active"
then
  echo "`date +'%Y%m%d:%H%M%S'` Service was active, restarting..."
  systemctl start charon_pluto

  sleep 30

  echo "`date +'%Y%m%d:%H%M%S'` Service status:"
  systemctl -l status charon_pluto
fi

if test ${RET:-0} -eq 0
then
  echo "`date +'%Y%m%d:%H%M%S'` Backup completion: success"
else
  echo "`date +'%Y%m%d:%H%M%S'` Backup completion: failure ${RET}"
fi

exit

Crontab entry

#=== Stop the charon_pluto service if it was running, backup the vdisk file and restart (if it was running)

00 20 * * * /charon/charon_backup_pluto >/charon/charon_backup_pluto.log 2>&1

(info) In the example above, the script will run everyday at 20:00 and will log the output to theĀ /charon/charon_backup_pluto.log file

Log example

# cat /charon/charon_backup_pluto.log
20200313:150719 Stopping charon_pluto service
20200313:150803 Waiting 60 seconds for full stop...
20200313:150903 Service status:
ā— charon_pluto.service - CHARON as4100/pluto - Tru64 V5.1b
Loaded: loaded (/etc/systemd/system/charon_pluto.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2020-03-13 15:08:03 CET; 1min 0s ago
Process: 29404 ExecStop=/opt/charon/utils/charon_gstart stop /charon/pluto.cfg (code=killed, signal=TERM)
Process: 28613 ExecStart=/opt/charon/utils/charon_gstart start /charon/pluto.cfg (code=exited, status=0/SUCCESS)
Main PID: 28916 (code=exited, status=0/SUCCESS)

Mar 13 15:07:19 toolkithost charon_gstart[29404]: [INFO ] Initiating pluto system shutdown via SSH
Mar 13 15:07:23 toolkithost charon_gstart[29404]: [INFO ] pluto is alive (responds to ping).
Mar 13 15:07:23 toolkithost charon_gstart[29404]: [INFO ] Initiating system shutdown
Mar 13 15:07:23 toolkithost charon_gstart[29404]: [INFO ] Waiting for shutdown completion...
Mar 13 15:07:24 toolkithost charon_gstart[29404]: [INFO ] pluto still responds to ping...
Mar 13 15:07:30 toolkithost charon_gstart[29404]: [INFO ] pluto still responds to ping...
Mar 13 15:07:36 toolkithost charon_gstart[29404]: [INFO ] pluto still responds to ping...
Mar 13 15:07:52 toolkithost charon_gstart[29404]: [INFO ] pluto does not respond to ping anymore.
Mar 13 15:08:02 toolkithost charon_gstart[29404]: [INFO ] Killing charon_pluto service
Mar 13 15:08:03 toolkithost systemd[1]: Stopped CHARON as4100/pluto - Tru64 V5.1b.
20200313:150903 Zipping /charon/disks/pluto_tru64.vdisk file
updating: pluto_tru64.vdisk (deflated 85%)
20200313:151009 Service was active, restarting...
20200313:151039 Service status:
ā— charon_pluto.service - CHARON as4100/pluto - Tru64 V5.1b
Loaded: loaded (/etc/systemd/system/charon_pluto.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2020-03-13 15:10:09 CET; 30s ago
Process: 29404 ExecStop=/opt/charon/utils/charon_gstart stop /charon/pluto.cfg (code=killed, signal=TERM)
Process: 29782 ExecStart=/opt/charon/utils/charon_gstart start /charon/pluto.cfg (code=exited, status=0/SUCCESS)
Main PID: 30085 (pluto)
Tasks: 34
CGroup: /system.slice/charon_pluto.service
ā””ā”€30085 /opt/charon/bin/as4100 -d /charon/pluto.cfg

Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] aksusbd monitor service status is: unknown
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] Log monitor service status is: inactive
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] Checking network settings...
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] Switching off all offload parameters for interface ens33
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] Switching off all offload parameters for interface ens38
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] Checking vdisk files if any...
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] Starting emulator: /opt/charon/bin/as4100 -d /charon/pluto.cfg
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] OOM process killing prevention is enabled
Mar 13 15:10:09 toolkithost charon_gstart[29782]: [INFO ] Process 30085 is now protected
Mar 13 15:10:09 toolkithost systemd[1]: Started CHARON as4100/pluto - Tru64 V5.1b.
20200313:151039 Backup completion: success



© Stromasys, 1999-2024  - All the information is provided on the best effort basis, and might be changed anytime without notice. Information provided does not mean Stromasys commitment to any features described.