Hello All! I am currently setting up an auto updating script and cronjob for backing up my Minecraft server. but I have run into an issue. When trying to make a tar.gz file with the date as it's name, I am getting a wierd bug(?). Please help me if you can.
I want this code to 'zip' into a file called, for example "Apr18_Fri.tar.gz" in the "/root/backups" (also known as "~/backups"). However, as it wasn't working, I was having it echo the variable back to me. This is what is came out as:
.targzps/Apr19_Sat
If anyone can tell me how to just get it to write correctly, I would greatly appreciate it.
Rollback Post to RevisionRollBack
Live life to the fullest; you never know what can happen in a moments notice.
Which outputs the strings correctly. I'm sure you can piece that back into the original script.
Sorry if I misinterpreted something, but you can also have a look at this script I threw together for myself years ago. It's meant to be run manually, but you should be able to salvage something from it.
It only backs up one world at a time, but it should be easy to tweak it to do the entire server directory.
#!/bin/bash
# Minecraft server backup script
workingDir=$(pwd)
serverDir=/srv/minecraft
worldName=$1
currentDate=$(date +%d-%m-%y-%s)
printUsage() {
echo "::"
echo "::"
echo ":: Usage is: mineback <worldname>."
echo "::"
echo "::"
}
runBackup() {
echo ":: Backing up $worldName to $serverDir/Backups/$worldName - $currentDate..."
cp -r "$serverDir/$worldName" "$serverDir/Backups/$worldName - $currentDate"
echo ":: Backup done!"
}
variableTest() {
echo "workingDir: $workingDir"
echo "serverDir: $serverDir"
echo "worldName: $worldName"
echo "currentDate: $currentDate"
echo "Backing up $worldName to $serverDir/$worldName - $currentDate..."
}
if [ ! -n "$1" ]
then
printUsage
else
runBackup
#variableTest
fi
: command not found
: command not found
Apr20_Sun
/root/backups
.tar.gzun
.tar.gzSunups
This is greatly confusing me also, as I would though it would have worked.
--------------------------------------------------------------------------------------------
After further testing, it seems the echo is ignoring all but my last variable in any script I attempt.
: command not found
: command not found
Apr20_Sun
/root/backups
.tar.gzun
.tar.gzSunups
This is greatly confusing me also, as I would though it would have worked.
--------------------------------------------------------------------------------------------
After further testing, it seems the echo is ignoring all but my last variable in any script I attempt.
try using shell, which has a few differences to bash, but should work much the same way, but as it feeds through a different interpreter, it may solve your issue, or go for a different distro such as debian or mint, but that would knock the server down for a few hours while it installs, unless you have a backup server or computer to install it to a second HDD and jam that into the server rig and transfer the server over, it should only take a few minutes of downtime if you do it that way
that should get you the file name you want with the compression you want, just make sure the naming is working before uncommenting the compression function (the .tgz is just a shorter version of .tar.gz)
http://pcpartpicker.com/p/2kUq0
the average script-follower/lack of common sense: http://www.techtales.com/tftechs.php?m=200504#8418
windoge 8 has the saddest excuse for a BSOD, it just tells you the type of error, no stop code, no nothing, just "something went wrong, all your unsaved work has now been lost to the void that is volatile memory"
: command not found
: command not found
Apr20_Sun
/root/backups
.tar.gzun
.tar.gzSunups
This is greatly confusing me also, as I would though it would have worked.
--------------------------------------------------------------------------------------------
After further testing, it seems the echo is ignoring all but my last variable in any script I attempt.
For what it is worth, I ran that code on two computers, one running Mint 13 and one on Debian 6 (Squeeze) and got the output you are looking for:
*mumble* *mumble* *something about Minecraft*
Click the image above to check out my vanilla server, PrimalCraft. IP: play.primalcraft.net.
Also check out my modded server, Electri!
Code Snippet:
I want this code to 'zip' into a file called, for example "Apr18_Fri.tar.gz" in the "/root/backups" (also known as "~/backups"). However, as it wasn't working, I was having it echo the variable back to me. This is what is came out as:
If anyone can tell me how to just get it to write correctly, I would greatly appreciate it.
"Nobody likes to fail. I want to succeed in everything I do, which isn't much. But the things that I'm really passionate about, if I fail at those, if I'm not successful, what do I have?"
"I say what I want to say and do what I want to do. There's no in between. People will either love you for it or hate you for it."
"The truth is you don't know what is going to happen tomorrow. Life is a crazy ride, and nothing is guaranteed."
Secondly, is this meant to be a Bash script? If so, you might want something more like:
Which outputs the strings correctly. I'm sure you can piece that back into the original script.
Sorry if I misinterpreted something, but you can also have a look at this script I threw together for myself years ago. It's meant to be run manually, but you should be able to salvage something from it.
It only backs up one world at a time, but it should be easy to tweak it to do the entire server directory.
Anyways, it didn't work. I made a test.sh and put this is in:
But it output as
I am running on CentOS 6.2, if that help anything.
"Nobody likes to fail. I want to succeed in everything I do, which isn't much. But the things that I'm really passionate about, if I fail at those, if I'm not successful, what do I have?"
"I say what I want to say and do what I want to do. There's no in between. People will either love you for it or hate you for it."
"The truth is you don't know what is going to happen tomorrow. Life is a crazy ride, and nothing is guaranteed."
Try something along the lines of:
My exact output:
This is greatly confusing me also, as I would though it would have worked.
--------------------------------------------------------------------------------------------
After further testing, it seems the echo is ignoring all but my last variable in any script I attempt.
"Nobody likes to fail. I want to succeed in everything I do, which isn't much. But the things that I'm really passionate about, if I fail at those, if I'm not successful, what do I have?"
"I say what I want to say and do what I want to do. There's no in between. People will either love you for it or hate you for it."
"The truth is you don't know what is going to happen tomorrow. Life is a crazy ride, and nothing is guaranteed."
EDIT: example script: that should get you the file name you want with the compression you want, just make sure the naming is working before uncommenting the compression function (the .tgz is just a shorter version of .tar.gz)
http://pcpartpicker.com/p/2kUq0
the average script-follower/lack of common sense: http://www.techtales.com/tftechs.php?m=200504#8418
windoge 8 has the saddest excuse for a BSOD, it just tells you the type of error, no stop code, no nothing, just "something went wrong, all your unsaved work has now been lost to the void that is volatile memory"
For what it is worth, I ran that code on two computers, one running Mint 13 and one on Debian 6 (Squeeze) and got the output you are looking for:
Click the image above to check out my vanilla server, PrimalCraft. IP: play.primalcraft.net.
Also check out my modded server, Electri!