I'm currently writing an advanced starting script for my minecraft server. Everything works out as I want it too. But the problem is the backups. I created a function for it. It works also great and does exactly what i want it to do. But since the server has to be down during the backup and the backup itself takes ages (I mean hours) I need to speed the backup up!
My current backup works like this:
tar -cjvf $BACKUP_PATH/$filename $MINECRAFT_PATH
As I said this takes ages!
So I had the idea to just make a tar file without compressing then start the server and then compress the archive.
tar -cvf $BACKUP_PATH/$filename $MINECRAFT_PATH START_SERVER bzip2 -9 $BACKUP_PATH/$filename rm $BACKUP_PATH/$filename
This should work faster. But then i had an idea. And this is the point where i need you.
First I wanted to modify the actual backupping in a way that shows how much is already backed up and an estimation how long it will approximately take to finish. Therefor the output of tar would bes supressed, the command would be run in the background and a (while) loop (that waits for the command to finish) would calculate the percentage calculated and also calculate an estimate of the remaining time.
To to this I would first make a call to
du to get the size of all files being compressed. This would be saved in a variable. the i would get the current timestamp. Also saved in a variable. At this point the loop would start. Then in the loop the percentage and the remaining time would be calculated (simple...) and this would be printed in two lines that always are updated. And this is my major problem. I would be very happy if someone could help me with the loop!
Some basic code:
tar -cf $BACKUP_PATH/$filename $MINECRAFT_PATH & backupsize=$(du -bs $MINECRAFT_PATH) starttimestamp=$(date +%s) # Here is the loop (how do I stay here while the tar command is still running? # And how do i update the two lines with the newly created numbers? START_SERVER bzip2 -9 $BACKUP_PATH/$filename rm $BACKUP_PATH/$filename
If you are in the helpy mood you can help me getting this kind of thing also to work for the
bzip command. If it's not possible I will just leave it! (
bzip accepts the same flags as