#!/bin/sh
echo ${origindir}
export infoSnapshot=[EALSNAPSHOT]
cd ${origindir}
export snapshotdir=${origindir}/saveSnapshot
mkdir ${snapshotdir}
export defaultfilesave=${origindir}/RaiseTheEmpires/fileSave
echo "${infoSnapshot} periodicSaveSnapshot have been launched"
while true ;do
snapshotTime=$(date +%Y%m%d_%H%M%S)
echo "${infoSnapshot} Creating save file Snapshot ${snapshotTime}"
echo default Filesave
ls ${defaultfilesave}
echo snapshotdir
ls ${snapshotdir}/${snapshotTime}
cp -rv ${defaultfilesave} ${snapshotdir}/${snapshotTime}
echo "${infoSnapshot} Finished backup"
sleep 600
procbelong=$(ls ${origindir}/proc | grep snapshot) # detects when the parent process PID terminated and doesnt exists anymore
if [ -z ${procbelong} ];then
echo "no parent process detected self termination initiated"
exit
fi
done
