Skip to content

Instantly share code, notes, and snippets.

@AutomationD
Last active March 28, 2018 17:03
Show Gist options
  • Save AutomationD/eaa7583f743f6f21d8a3 to your computer and use it in GitHub Desktop.
Save AutomationD/eaa7583f743f6f21d8a3 to your computer and use it in GitHub Desktop.
Ramdisk persitance daemon
#!/bin/sh
# /etc/init.d/ramdisk-manage
#
case "$1" in
start)
echo "Syncing files from harddisk to ramdisk"
rsync -av /var/lib/ramdisk-persisance/ /mnt/ramdisk/
echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched from HD >> /var/log/ramdisk-manage.log
;;
sync)
echo "Syncing files from ramdisk to harddisk"
echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk-manage.log
rsync -av --delete --recursive --force /mnt/ramdisk/ /var/lib/ramdisk-persisance/
;;
stop)
echo "Syncing files from ramdisk to harddisk"
echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk-manage.log
rsync -av --delete --recursive --force /mnt/ramdisk/ /var/lib/ramdisk-persisance/
;;
*)
echo "Usage: /etc/init.d/manage-ramdisk {start|stop|sync}"
exit 1
;;
esac
exit 0
update-rc.d ramdisk-manage defaults 00 99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment