Results 1 to 1 of 1

Thread: Automated linux file backup w/Webmin

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    g0d! Contributing Member siosios's Avatar
    Join Date
    Oct 2006
    Location
    In a cardboard box
    Age
    51
    HlStats

    HLStatsX Ranking for STEAM_0:1:13488560
    Posts
    13.570
    Blog Entries
    12
    Rep Power
    10

    Default Automated linux file backup w/Webmin

    Automated linux file backup w/Webmin


    As I manage 3 linux server computers, it became more apparent I needed to setup some kind of automatic backup method of certain data for the game servers that I manage. After about 4 hours of working, I created that system I needed and im sharing the method and custom scripts I coded to do this. (This is tested on a RHEL based distro, but will probably work on any RHEL or dabien linux distro). When copying the below code, you need to put it into a notepad and save it as a something.sh? file.
    The following is an example of Counter-Strike Source automated backup (but it can be adapted to anything on the server).

    Code:
    echo Backing up Server /cfg?
    echo Appending Date
    echo Transfering Directories
    echo 
    echo cd ./home/server/
    tar czvfC $1server.$(date +%Y%m%d%-%H%M%S).tgz $1 /home/server/cstrike/cfg /home/server/cstrike/cfg
    echo done
    echo ?
    echo Location= /home/server/backup/?
    Where the echos are just for information and keeping track of the script and what its doing. The tar command will go out to a directory, compress it and put it into the current directory the SH script is in and append a date to it. All you need to do is to type sh serverbackup.sh? in shell. Later Ill talk about setting up cron jobs to automatically do this without any user intervention. Server indicates what you want the tar ball to be named with the date appended to it. Server, you replace it with the backup directory you want.

    Now to keep this easy with setting up cron jobs, youll need to put another SH script in the home directory of the server.

    Put this backup.sh? file into the home directory for the user (easier for setting up cron jobs)

    cd ./backup
    sh serverbackup.sh

    This will change directory to where the backup location is (in this case, its a folder in the home directory labeled backup?), then the script execs the serverbackup.sh file and does the backup. This way it keeps a ton of backup files out of the home directory and out of the servers hair so to speak by having its own folder to store them in.

    Next youll want to create a masterbackup.sh? file to forcibly invoke any sh backup location that is designated.

    Here is an example of such a script that I use:

    Code:
     
    echo Executing MasterBackup
     
     
    cd ..
     
     
    echo Server1?
     
     
    cd ./home/server1/
     
     
    sh backup.sh
     
     
    echo ..check
     
     
    echo Server2?
     
     
    cd ..
     
     
    cd ./server2
     
     
    sh backup.sh
     
     
    echo ..check
     
     
    echo Server3?
     
     
    cd ..
     
     
    cd ./Server3
     
     
    sh backup.sh
     
     
    echo ..check
     
     
    echo Server4?
     
     
    cd ..
     
     
    cd ./server4
     
     
    sh backup.sh
     
     
    echo ..check
     
     
    echo Server5??
     
     
    cd ..
     
     
    cd ./server5
     
     
    sh backup.sh
     
     
    echo ..check
     
     
    echo Finished MasterBackup
    ?

    Where the server#? is a seperate home directory of a game server, the script cds to the first server, then backs out 1 directory and cds to the next home directory and execs the backup script which in turn invokes the backup script of the server in a daisy chain effect. Put this script in /root (or adapt it yourself for somewhere else)
    This can all be automated using cron jobs. Login to webmin, goto system? and click on cron jobs? module. From here, create a new cron put in the user of the game server (or anything else) and it will automatically when it runs the cron job, cd to the home directory, therefore you need to put sh backup.sh as the command? which will exec the first script (which in turn cds to the backup folder directory and execs the real backup script for that user account). Set the time you want the backup to happen (I use once every 24 hours) and create it.

    All done, you now have an automatic backup every 24 hours of a Counter-Strike (TS or any other use) important config information stored in a seperate directory.

    Now, 1 other thing I do, on a weekly basis. I run a partial game server backup every week and backup the /cfg, /addons, /logs folder of each game server on the linux box. For this I use:

    Code:
     
    echo Backing up Computer??
     
     
    echo Appending Date??
     
     
    tar czvfC $1il.$(date +%Y%m%d%-%H%M%S).tgz $1 /home/server1/cstrike/cfg 
    /home/server1/cstrike/cfg /home/server1/cstrike/addons 
    /home/server1/cstrike/addons /home/server1/cstrike/logs 
    /home/server1/cstrike/logs /home/server2/cstrike/cfg /home/server2/cstrike/cfg 
    /home/server2/cstrike/addons /home/server2/cstrike/addons 
    /home/server2/cstrike/logs /home/server2/cstrike/logs /home/server3/cstrike/cfg 
    /home/server3/cstrike/cfg /home/server3/cstrike/addons 
    /home/server3/cstrike/addons /home/server3/cstrike/logs 
    /home/server3/cstrike/logs /home/server4/cstrike/cfg /home/server4/cstrike/cfg 
    /home/server4/cstrike/addons /home/server4/cstrike/addons 
    /home/server4/cstrike/logs /home/server4/cstrike/logs /home/teamspeak/tss2_rc2 
    /home/teamspeak/tss2_rc2
     
     
    echo done
     
     
    echo
     
     
    echo Location= /root/backup/?
    This script will backup any folders you want to any backup location (in this case /root/backup) and setup as a cron job.

    Feel free to use this system and/or comment on it, If something is confusing, let me know and ill further clarify it.

    *edit* make sure to set the permissions correctly or it will not work, must have 0755 permission assigned to the correct shell user account and group, otherwise when it goes to backup with the cron jobs, it gets a access denied and doesnt backup.
    Last edited by siosios; 08-28-2011 at 08:29 PM.
    ------------------------------------------------

    |W0rd|SexualTurtletara420ת/ύ: Hey there daddy..

    ------------------------------------------------
    \\\ ///
    ( @ @ )
    .....o00o.(_).o00o.....


    ------------------------------------------

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Webmin Game Control Panel Guide
    By siosios in forum Server Tech Talk
    Replies: 1
    Last Post: 04-25-2009, 12:41 PM
  2. Cloning Linux drives (notes for sio)
    By siosios in forum Server Tech Talk
    Replies: 6
    Last Post: 12-08-2008, 06:10 PM
  3. How-to detect a possible intruder ¿? (Linux Server)
    By siosios in forum Server Tech Talk
    Replies: 1
    Last Post: 11-16-2008, 04:46 PM
  4. About the Random Automated Team switchermaticmabob.
    By Shad in forum Regular Office
    Replies: 20
    Last Post: 01-15-2008, 11:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •