endofzero / Minecraft-Sheller

Shell script designed to allow for automation of Minecraft Server Administration.
62 stars 18 forks source link

Backups not clearing #40

Open Kdehner opened 12 years ago

Kdehner commented 12 years ago

My minecraft.sh backup full is not clearing out old backups when run every night. Its backing up properly and i am getting full backups in my folder but non of the incriminates past 2 days are being removed and none of the full backups past 5 days are being removed. i have posted my Cron Jobs and the part of my .sh that has the backups.

Cron Job 3,18,33,48 * * * * /home/***_/****/minecraft.sh sync >/dev/null 2>&1 5 1,5,7,9,11,13,15,17,19.21,23 * * * /home/**/_****/minecraft.sh backup 5 3 * * * /home/****/*****/minecraft.sh backup full

Minecraft.sh Backups BKUP_PATH=/home/****/minecraft_backups BKUP_DAYS_INCR=2 BKUP_DAYS_FULL=5

ALT_BACKUP=1 ALT_PATH=$MC_PATH/plugins

Also has full support been added for the plugins backup?

endofzero commented 12 years ago

This is the code that builds the purge list. If you go into the backup directory and run the commands below (changing the $BKUP_ values to be the real numbers)

find *-incr.tgz -type f -mtime +$BKUP_DAYS_INCR -print > purgelist

find *-full.tgz -type f -mtime +$BKUP_DAYS_FULL -print >> purgelist

Then check the 'purgelist' file that it created to see what files it found, or just remove the '>/>> purgelist' and it should print directly to the terminal.

Cyph3r commented 12 years ago

that's because the script is borked. If condition with -e (exists) arg is not setup correctly for wildcard searching when there is more than 1 result.

Change the lines from:

touch purgelist if [[ -e $BKUPPATH/$WORLD/-incr.tgz ]]; then find $WORLD/_-incr.tgz -type f -mtime +$BKUP_DAYS_INCR -print > purgelist fi if [[ -e $BKUPPATH/$WORLD/-full.tgz ]]; then find $WORLD/_-full.tgz -type f -mtime +$BKUP_DAYS_FULL -print >> purgelist fi

to:

touch purgelist if [[ -e echo $BKUP_PATH/$WORLD/*-incr.tgz | cut -d " " -f1 ]]; then find $WORLD/_-incr.tgz -type f -mtime +$BKUP_DAYS_INCR -print > purgelist fi if [[ -e echo $BKUP_PATH/$WORLD/_-full.tgz | cut -d " " -f1 ]]; then find $WORLD/*-full.tgz -type f -mtime +$BKUP_DAYS_FULL -print >> purgelist fi

(Code doesn't seem to be showing up exactly right in this comment. See: http://pastebin.com/nd7A3kgG )

Cyph3r commented 12 years ago

Also, the plugins stuff was never added by the developer, unfortunately. The variables are just dummy placeholders.

endofzero commented 12 years ago

If you want to add a pull request for any changes, I'll be glad to merge them.

I've been quite busy to be able to work on this, but I will be glad to merge any work that anyone else does.