Guest User

backup_world.sh

a guest
Oct 22nd, 2020
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. set -eu -o pipefail
  3.  
  4. # Backup 8675309 worlds
  5. /usr/bin/date;
  6. /usr/bin/du /opt/minecraft/server/snapshots/ --human-readable;
  7.  
  8. /usr/bin/echo "Save World Now"
  9. /opt/minecraft/tools/mcrcon/mcrcon -H HOST -P MCRCON_PORT -p MCRCON_PASS save-off;
  10. /opt/minecraft/tools/mcrcon/mcrcon -H HOST -P MCRCON_PORT -p MCRCON_PASS save-all;
  11. /usr/bin/sleep 10s;
  12.  
  13. /usr/bin/echo "Clear Backups Older than 14 days"
  14. /usr/bin/find /opt/minecraft/server/snapshots/*.zip -mtime +14 -exec /usr/bin/rm {} \ || true;
  15. /usr/bin/echo "Begin Backups"
  16. cd /opt/minecraft/server/
  17. /usr/bin/zip --verbose snapshots/8675309/`date "+%Y-%m-%d-%H-%M-%S"`.zip --recurse-paths 8675309;
  18. /usr/bin/zip --verbose snapshots/8675309_nether/`date "+%Y-%m-%d-%H-%M-%S"`.zip --recurse-paths 8675309_nether;
  19. /usr/bin/zip --verbose snapshots/8675309_the_end/`date "+%Y-%m-%d-%H-%M-%S"`.zip --recurse-paths 8675309_the_end;
  20. /usr/bin/echo "Re-enable Saving"
  21. /opt/minecraft/tools/mcrcon/mcrcon -H HOST -P MCRCON_PORT -p MCRCON_PASS save-on;
  22. /usr/bin/du /opt/minecraft/server/snapshots/ --human-readable;
  23. /usr/bin/date;
  24.  
  25. #exit 0;
  26.  
RAW Paste Data