automating backups? (headless linux server)

  • 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

draeath

New Member
Jul 29, 2019
456
0
0
Hi folks!

Does anyone have any working solution for automating world backups? If you do, here's a few caveats - but if you know how to talk to the server skip down, as I can implement the rest myself and would prefer to do that in fact!
  1. I would prefer something open source.
  2. Keep It Simple; Stupid - I've looked through a few wrappers like mark2 and frankly that's way beyond what I need. I want for nothing beyond backups.
  3. I have no GUI, this is a headless Linux box
  4. I want to back up the whole directory, not just the world. Logs, configs and all.
I can do everything myself, except I do not know how to send commands to the server (or read back if it worked or not) such as save-all, save-on, save-off. If I could do that, I would be comfortable implementing a DARdifferential backup scheme (to save disk space).

If you have never heard of dar before check it out, even if you don't use Linux! Dar is, frankly, awesome. Have a look at the feature list.
 

Greylocke

New Member
Jul 29, 2019
66
0
0
Since it looks like you want to build your own solution, I won't post the entire script. Honestly, most of the script I use comes from the Minecraft wiki anyway. :) (http://www.minecraftwiki.net/wiki/Tutorials/Server_startup_script) I use cron to call a script that usesrdiff-backup (http://rdiff-backup.nongnu.org/) to do incremental backups of my server files. I do world backups every 15 minutes, and full server backups daily.

Here are the 3 most important parts of the script. This should give you some ideas for how to do what you want. Have fun!
Code:
mc_saveoff() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
      as_user "screen -x -X eval 'stuff \"save-off\"\015'"
      sleep 2
      echo "saveoff: forcing changes to disk"
      as_user "screen -x -X eval 'stuff \"save-all\"\015'"
      sync
      sleep 10
    else
      echo "saveoff: $SERVICE was not running. Not suspending saves."
    fi
}
 
mc_saveon() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
      as_user "screen -x -X eval 'stuff \"save-on\"\015'"
    else
      echo "saveon: $SERVICE was not running. Not resuming saves."
    fi
}
 
mc_rdiffbackup() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
      as_user "rdiff-backup $RDIFFSTRING $BACKUPPATH"
    else
      echo "rdiffbackup: Service is not running. Not performing rdiff-backup."
    fi
}
 
  • Like
Reactions: darkinnit

draeath

New Member
Jul 29, 2019
456
0
0
I think I follow - you are sending the text 'save-on' and 'save-off' to the terminal via screen? I didn't realize that could be done... cool!
 

longplayer

New Member
Jul 29, 2019
20
0
0
if you got good amount of hdd space make it like this: http://wiki.ess3.net/wiki/Backup


i use 2 worlds so i change a bit to pack both and not only the world and plugin folder in a zip where ftb-public and ftb-private are to server root folders and the folder backups/ exist where the location of the script ist, then add it to crontab, over essentials i use every 60 minutes save and this script is running every full hour

Code:
#!/bin/bash
#Set these values to match your server's settings.

# This script should be located in the craftbukkit folder

# Make sure you change this to the name of your world folder! 
# Add additional worlds by separating them with a space.
declare -a worlds=(ftb-public ftb-private)
backupdir=backups/
ext=.zip
 
hdateformat=$(date '+%Y-%m-%d-%H-%M-%S')H$ext
ddateformat=$(date '+%Y-%m-%d')D$ext
numworlds=${#worlds[@]}
 
    echo "Starting multiworld backup..."
 
    if [ -d $backupdir ] ; then
        sleep 0
    else
        mkdir -p $backupdir
    fi
 
    for ((i=0;i<$numworlds;i++)); do
        zip -q $backupdir$hdateformat -r ${worlds[$i]}
        echo "Saving '${worlds[$i]}' to '$backupdir$hdateformat'."
    done
    cp $backupdir$hdateformat $backupdir$ddateformat
    echo "Updated daily backup."
    find $backupdir/ -name *H$ext -mmin +1440 -exec rm {} \;
    find $backupdir/ -name *D$ext -mtime +14 -exec rm {} \;
    echo "Removed old backups."
 
    echo "Backup complete."
 
exit 0
 
exit 0
 

MigukNamja

New Member
Jul 29, 2019
2,202
0
0
I also was searching for the same thing and found ForgeBackup. It's a coremod, requires no scripts or client-side support, and you can configure it via its config file on the standard configs directory. In-game, ops can do manual backups with the /backup command. Installation is as easy as dropping it in your coremods folder and restart the server.

I believe it can do backups to a DropBox account as well, whether in ForgeBackup itself, or pointing it to a folder/directory that is managed by the DropBox local process.