mirror of
https://github.com/msmhq/msm.git
synced 2024-08-30 18:12:35 +00:00
Implemented "server backup", and re-added the DEFAULT_COMPLETE_BACKUP_FOLLOW_SYMLINKS setting.
This commit is contained in:
32
msm
32
msm
@ -844,6 +844,24 @@ server_log_roll() {
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
# Backups a server's directory
|
||||
# $1: The ID of the server
|
||||
server_backup() {
|
||||
echo -n "Backing up the entire server directory... "
|
||||
|
||||
zip_flags="-rq"
|
||||
# Add the "y" flag if symbolic links should not be followed
|
||||
if [ "${server_complete_backup_follow_symlinks[$1]}" != "true" ]; then
|
||||
zip_flags="${zip_flags}y"
|
||||
fi
|
||||
|
||||
# Zip up the server directory
|
||||
file_name="${server_backup_path[$1]}/$(date "+%F-%H-%M-%S").zip"
|
||||
as_user ${server_user_name[$1]} "mkdir -p \"${server_backup_path[$1]}\" && cd \"${server_path[$1]}\" && zip ${zip_flags} \"${file_name}\" ."
|
||||
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
|
||||
### Main Functions
|
||||
|
||||
@ -891,6 +909,7 @@ init() {
|
||||
server_confirm_save_off[$i]="$DEFAULT_CONFIRM_SAVE_OFF"
|
||||
server_confirm_save_all[$i]="$DEFAULT_CONFIRM_SAVE_ALL"
|
||||
server_confirm_start[$i]="$DEFAULT_CONFIRM_START"
|
||||
server_complete_backup_follow_symlinks[$i]="$DEFAULT_COMPLETE_BACKUP_FOLLOW_SYMLINKS"
|
||||
|
||||
|
||||
# Load config overrides from server config file if present
|
||||
@ -931,6 +950,7 @@ init() {
|
||||
CONFIRM_SAVE_OFF) server_confirm_save_off[$i]="$value";;
|
||||
CONFIRM_SAVE_ALL) server_confrim_save_all[$i]="$value";;
|
||||
CONFIRM_START) server_confrim_start[$i]="$value";;
|
||||
COMPLETE_BACKUP_FOLLOW_SYMLINKS) server_complete_backup_follow_symlinks[$i]="$value";;
|
||||
esac
|
||||
done < "${server_conf[$i]}"
|
||||
fi
|
||||
@ -1317,6 +1337,18 @@ main() {
|
||||
server_log_roll $id
|
||||
;;
|
||||
backup)
|
||||
if server_is_running $id; then
|
||||
server_eval $id "say ${server_complete_backup_started[$id]}"
|
||||
server_save_off $id
|
||||
server_save_all $id
|
||||
fi
|
||||
|
||||
server_backup $id
|
||||
|
||||
if server_is_running $id; then
|
||||
server_save_on $id
|
||||
server_eval $id "say ${server_complete_backup_finished[$id]}"
|
||||
fi
|
||||
;;
|
||||
whitelist|wl)
|
||||
;;
|
||||
|
9
msm.conf
9
msm.conf
@ -70,6 +70,12 @@ DEFAULT_SCREEN_NAME="msm-{SERVER_NAME}"
|
||||
# A directory name relative to the server directory where worlds are stored
|
||||
DEFAULT_WORLD_STORAGE_PATH="worldstorage"
|
||||
|
||||
# "true" and symlinks are followed when performing a complete backup,
|
||||
# "false" and symlinks are replaced in the zip with a file containing the
|
||||
# path to the original symlink larget, this saves space.
|
||||
DEFAULT_COMPLETE_BACKUP_FOLLOW_SYMLINKS="false"
|
||||
|
||||
|
||||
# The location of the standard Minecraft log file, relative to the
|
||||
# server directory
|
||||
DEFAULT_LOG="server.log"
|
||||
@ -90,6 +96,7 @@ DEFAULT_RAM="1024"
|
||||
# all servers using the values.
|
||||
DEFAULT_INVOCATION="java -Xms{RAM}M -Xmx{RAM}M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -jar {JAR} nogui"
|
||||
|
||||
|
||||
# The default time to delay between warning players the server is stopping and
|
||||
# actually stopping the server:
|
||||
DEFAULT_STOP_DELAY=10
|
||||
@ -98,6 +105,7 @@ DEFAULT_STOP_DELAY=10
|
||||
# and actually restarting the server:
|
||||
DEFAULT_RESTART_DELAY=10
|
||||
|
||||
|
||||
# The default message to send to players on a server which is about to be
|
||||
# shut down. You may use the tag "{DELAY}" to specify the time delay
|
||||
# before shutdown:
|
||||
@ -132,6 +140,7 @@ DEFAULT_COMPLETE_BACKUP_STARTED="Backing up entire server."
|
||||
# entire server directory:
|
||||
DEFAULT_COMPLETE_BACKUP_FINISHED="Backup complete."
|
||||
|
||||
|
||||
# The message once logged confirms the "save-on" command has finished
|
||||
DEFAULT_CONFIRM_SAVE_ON="CONSOLE: Enabling level saving.."
|
||||
|
||||
|
Reference in New Issue
Block a user