Made a bash script to archive server files to zip, does server need to be stopped to run it?

Discussion in 'Systems Administration' started by Metropolis, Jun 24, 2016.

  1. Hey all! I made a bash script to backup my spigot directory to a zip file in a different location. I was considering automating it, but wondered, does running such a script require the server to be stopped each time?
     
  2. I'm guessing you could put it in a screen then somehow make a script to do a command without going into the screen to do /save-all
    Code (Text):
    screen -S screen_name-X stuff "command 1"'echo -ne '\015''"command 2"'echo -ne '\015''
    then back it up how you would then somehow get it to repeat it? Not sure how you would do it do you mind me seeing the bash script
     
    • Useful Useful x 1
  3. just do
    Code (Text):
    cp SERVERFOLDER SERVERFOLDER
    Is that what you needed?
     
    • Funny Funny x 1
    • Useful Useful x 1
  4. You may loose some data. For example some plugins store information on disable or at an interval. If it is called in onDisable, nothing will be saved because it was not disabled.

    People don't really do that because onDisable is not that safe. You should be fine to just copy everything and move it over.
     
    • Winner Winner x 1
  5. Code (Text):

    #!/bin/bash

    now=$(date +"%m_%d_%Y")
    zip -r /mnt/backups/mcss/mcss_x_$now.zip /root/mcss
    echo "Backed up :)"
     
    The script works, my question was essentially would running this script while the server is running cause any conflicts? I could always manually run the script in a different screen or with the server shut off, but I was curious if there would be possible data corruption in the back up due to the server running while I was copying the files to the zip.

    Edit: Ah Synapz, I was typing my reply when you posted yours. That was what I was wondering. So more or less, I should be ok to go archive the server while it runs? Or was I misunderstanding when you said "you should just be fine" lol

    Edit 2: Ok I re-read and I understand, I should be good. I only run a few plugins (<5) and none of them require any kind of saving.
     
    • Like Like x 1
  6. If you are really really scared the plugin monster will come get you....

    Just have the server restart auto once a night (which is good anyway for the server) When server stops make a quick backup and start the server again. But your good either way :p but you never know the plugin monster is coming...