I looked far and wide for a nice, simple backup script I can run locally on my servers.
When I was renting from a hosting service, they used Windows, and I submitted a backup script written in BATCH.
When I switched over to a dedicated server, I decided to run a Linux distribution and wrote a basic BASH script.
Currently, these are only meant to save the backup.
There are currently no means of restoring the backup, nor pruning backups.
**These have been tested to work, but have not been extensively tested. Anything that happens IS NOT MY RESPONSIBILITY.
So that, over the course of 2 days, there will be backups consisting of 1, 2, 3, 4, 5, 10, 15, 20, 30, 40, 50, 60, 90, 120, ... minute intervals along with a command that can be run via command line to restore a selected backup to the server, prune backups, backup at that specific moment, or do a full backup (all tables and data, including structure)
I've also been working on a script that will run the DayZ server via command line. It has not been going as planned.
When I was renting from a hosting service, they used Windows, and I submitted a backup script written in BATCH.
When I switched over to a dedicated server, I decided to run a Linux distribution and wrote a basic BASH script.
Currently, these are only meant to save the backup.
There are currently no means of restoring the backup, nor pruning backups.
**These have been tested to work, but have not been extensively tested. Anything that happens IS NOT MY RESPONSIBILITY.
For Windows
========================- Create a new file in any directory and name it autobackup.bat
- Put the following script in:
Code:@echo off set hr=%time:~0,2% if "%hr:~0,1%" equ " " set hr=0%hr:~1,1% SET backupTime=%date:~-4,4%-%date:~-10,2%-%date:~-7,2%_%hr%-%time:~3,2% REM echo %backupTime% cd "path\to\mysql\bin" mysqldump.exe --user=USERHERE --password=PASSWORDHERE --compact --replace --skip-lock-tables DATABASEHERE instance_deployable instance_vehicle profile survivor > "path\to\backups\%backupTime%.sql" REM pause
- Edit the script accordingly (directories, user, password, database)
- Set up a Windows service to run however many times you want per hour (5 minutes is ample) with the autobackup.sh to run
For Linux
========================- Create a new file in any directory and name it autobackup.sh
- Put the following script in:
Code:#!/bin/bash timeout=300 location="/media/games/backups/arma" cd $location; while true do file=$(date +"%H-%M") directory=$(date +"%m-%d-%Y") if [ ! -d "$directory" ]; then mkdir /home/arma/backups/$directory fi mysqldump --user=USERHERE --password=PASSWORDHERE --compact --replace --skip-lock-tables DATABASE instance_deployable instance_vehicle profile survivor > "$directory/$file.sql" echo "Backup Created at $location/$directory/$file.sql" sleep $timeout done
- Edit the script accordingly (directories, user, password, database)
- chmod +x autobackup.sh
- Set up a screen process or just run the script via command line, I'm sure if you're using Linux you wont need more detail
Screen
=======
- Install the package Screen (yum install screen, apt-get install screen, etc)
- Create dayzautobackup in your /usr/bin directory
- chmod +x /usr/bin/dayzautobackup
- Copypasta the following (and edit accordingly):
Code:#!/bin/sh file="/media/games/backups/arma/autobackup.sh" screen="dayzautobackup" #Determine whether or not screen is already running RUNNING=`screen -ls | grep $screen` case "$1" in 'start') cd $LOCATION RUNNING=`screen -ls | grep $screen` if [ "$RUNNING" = "" ] then screen -dmS $screen $file fi ;; 'stop') screen -x $screen -X quit ;; 'restart') screen -x $screen -X quit RUNNING=`screen -ls | grep $screen` cd $LOCATION until [ "$RUNNING" = "" ] do RUNNING=`screen -ls | grep $screen` done screen -dmS $screen ;; 'view') screen -x $screen ;; 'sv') cd $LOCATION if [ "$RUNNING" = "" ] then screen -dmS $screen $file fi sleep 1 screen -x $screen ;; *) echo "Usage: $0 { start | stop | restart | view | sv (start & view) }" ;; esac exit 0
- Then simply run dayzautobackup from via command line and it will pop up with a usage dialog
So that, over the course of 2 days, there will be backups consisting of 1, 2, 3, 4, 5, 10, 15, 20, 30, 40, 50, 60, 90, 120, ... minute intervals along with a command that can be run via command line to restore a selected backup to the server, prune backups, backup at that specific moment, or do a full backup (all tables and data, including structure)
I've also been working on a script that will run the DayZ server via command line. It has not been going as planned.