bash script autobackup

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

smenes

New Member
Jul 29, 2019
167
0
1
hi
before I was using mod for auto backup, but there is no mod for 1.6.4

I'm pretty n00b for bash script, so I need your help to find a good one.

I have find this one but I don't know if it's good https://github.com/benjick/Minecraft-Autobackup

what I need:
- auto backup every X hour for /world and /config directory
- remove old backup after X days
- notify in game when the script is running

I'm running Debian 7 (CLI) on dedicated server
server is running in a screen session

thank for your help

EDIT: also find this https://github.com/mide/linux-minecraft-scripts/blob/master/mc-backup.sh
 
Last edited:

Connor Gavitt

New Member
Jul 29, 2019
1,091
-1
0
I'm a simple guy, I have scheduled tasks that copy/paste all the files in a new spot then compress them every few hours.

every 12 hours I have it

Code:
cp /home/game /home/backup -r;zip filenamehere -r

Just used webmin to schedule the tasks. Simple yet effective :p
 

potop999

New Member
Jul 29, 2019
61
0
0
You could try this:
Code:
#!/bin/bash

# Turning world-save off and broadcast msg ING
screen -S ftb -X stuff "say Starting backup. World not saving... $(printf '\r')"
screen -S ftb -X stuff "save-off $(printf '\r')"
screen -S ftb -X stuff "save-all $(printf '\r')"

sync
sleep 10

# Backup with zip
zip -v /your/path/here/`date "+%Y-%m-%d-%H-%M-%S"`.zip -r world

sleep 5

# Turning world-save on and broadcast msg
screen -S ftb -X stuff "save-on $(printf '\r')"
screen -S ftb -X stuff "say Backup complete. World saving... $(printf '\r')"

Then add a cronjob to run it once every X hours.

I'm a simple guy, I have scheduled tasks that copy/paste all the files in a new spot then compress them every few hours.

every 12 hours I have it

Code:
cp /home/game /home/backup -r;zip filenamehere -r

Just used webmin to schedule the tasks. Simple yet effective :p

How does it react on file changes? Since the files might change while copying with save still on.
 
  • Like
Reactions: Francis Baster

DZCreeper

New Member
Jul 29, 2019
1,469
0
1
You could try this:
Code:
#!/bin/bash

# Turning world-save off and broadcast msg ING
screen -S ftb -X stuff "say Starting backup. World not saving... $(printf '\r')"
screen -S ftb -X stuff "save-off $(printf '\r')"
screen -S ftb -X stuff "save-all $(printf '\r')"

sync
sleep 10

# Backup with zip
zip -v /your/path/here/`date "+%Y-%m-%d-%H-%M-%S"`.zip -r world

sleep 5

# Turning world-save on and broadcast msg
screen -S ftb -X stuff "save-on $(printf '\r')"
screen -S ftb -X stuff "say Backup complete. World saving... $(printf '\r')"

Then add a cronjob to run it once every X hours.

For anyone wondering, this latches onto a Screen session with the label ftb then it informs players a backup is starting. It then turns off saving of the world and waits 10 seconds. It then creates zip file of the backup labelled with the year, month, day, hour, minute, and second, it then sleeps 5 seconds.

It then turns world saving back on and tells the players that the backup is complete. A cronjob is a way of scheduling events with a Linux OS.