BEST WAY TO SCHEDULE DAILY RESTARTS AND WORLD BACKUPS ON A LINUX DEDICATED SERVER

backupsdedicated-serverlinuxsystemd3 replies · 27 views · started
  1. ok weird one hey, looking for advice on running a game server on Linux properly. right now its started from a terminal session that I leave open, which feels fraglie.

    i want it to start on boot, restart if it crashes, and get backed up daily. im comfortable with the command line but havent written systemd units before.

    rage

    1
  2. hmmm dont keep backups only on the same disk as the server. if that drive dies, u lose both. copy them somewhere else periodically, another machine, a NAS, or an external drive. and actually test restoring one now and then; a backup youve never restored is a hope, not a backup.

    2 1 helpful
  3. hmmm run teh sevrer as a systemd service first... that gives u start on boot and restart on crash for free:

    [Unit]
    Description=Game server
    After=network-online.target
    
    [Service]
    User=gameserver
    WorkingDirectory=/opt/gameserver
    ExecStart=/opt/gameserver/start.sh
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    

    then systemctl enable --now gameserver.

    let us know how it goes.

    8 1 helpful
  4. yeahhh for the backup, a short script that stops the server, archives the world, and starts it again is safest, since copying files while the server is writing them can give you a corrupt backup:

    #!/bin/bash
    set -e
    systemctl stop gameserver
    tar -czf /backups/world-$(date +%F).tar.gz -C /opt/gameserver world
    systemctl start gameserver
    find /backups -name 'world-*.tar.gz' -mtime +7 -delete
    

    Run it nightly from a systemd timer or roots crontab.

    good luck! good luck man!

    0 5 helpful

Reply to this topic

Sign in or create an account to reply.