ISPConfig 3 - back-res a Backup and Restore script

Discussion in 'Plugins/Modules/Addons' started by go0ogl3, Dec 6, 2009.

  1. go0ogl3

    go0ogl3 New Member

    Thanks for pointing this out. The computer variable can be set like this:
    The implicit setting for me is:
    COMPUTER=`cat /etc/HOSTNAME | awk 'NR==1{print $1}'`
    just because I use mainly Slackware for many servers and the hostname file is /etc/HOSTNAME.
    The first version of the script was from a Ubuntu server so it uses /etc/hostname.

    Hope this helps!
    Last edited: May 9, 2010
  2. dipeshmehta

    dipeshmehta New Member

    Hello All,

    Although the script is working fine, I have some problem backing up few home folders. Some of users' home folders' have '_' in their names. It has been clearly mentioned in the headers of the script that, '...Weird things can happen if your backup dirs includes the "-" or "_" chars.' I cannot change names of these folders now. If possible, please guide me to solve the problem.

  3. go0ogl3

    go0ogl3 New Member

    You have to replace those characters, which are "hardcoded" in the script. Begin reading the code with the line: "#Replace / with _ in dir name => filename" I hope you will understand what's going on. Choose another character to replace "/" and if it's a smarter choice write here so we can update the script :) to help other people too.

    If you need more help write here. I'll read this forum more often these days to help you if you need.
  4. Torch_za

    Torch_za New Member

    No Mail on completion

    When the backup runs via cron the code suggests an email is generated and sent to the 'responsible person'. Is it just me or does this not work? The backup runs - there are log file entries and tar files in the right place but no "Success" email. When I ran the code with a trace it looks like that line is never executed?

    Using the latest script on 5 Debian ISPConfig3 servers.
    Last edited: May 30, 2010
  5. go0ogl3

    go0ogl3 New Member

    You have to check your mail command. There are 2 lines in the script which are used to send mail. Just search for "mail -s"
    You can test if the mail command works using some test command:

    mail -s "Subject" "[email protected]" < "datatext"
  6. Torch_za

    Torch_za New Member

    Not the problem ..

    Mail on all servers runs just fine... it has to... they are production servers.

    If I run the (modified - variables are substituted) line from a shell, it runs and the mail is sent. It's the back-res script that does not seem to fire the line...

    The safe tail of the trace (set -x)

    + echo '2010-05-30 19:12:48 - back-res - Daily backup for /var done.'
    + rm -rf /backup/tmpbck/full-backup_var.lck
    + rm -rf /backup/tmpbck/excluded
    + log 'All backup jobs done. Exiting script!'
    ++ date '+%Y-%m-%d %H:%M:%S'
    + acum='2010-05-30 19:12:48'
    + '[' -e /backup/server.domain.tld/log/backup.log ']'
    ++ basename ./back-res
    + echo '2010-05-30 19:12:48 - back-res - All backup jobs done. Exiting script!'
    ++ basename ./back-res
    + echo '2010-05-30 19:12:48 - back-res - All backup jobs done. Exiting script!'
    + exit 1

    As you can see the line is never reached or executed...
    Last edited: May 30, 2010
  7. go0ogl3

    go0ogl3 New Member

    You are right, the line which sends mail is in the restore part of the script... So mail is send only at restore. My mistake. The backup part does not send mail. I'll correct this as soon as possible. Thanks for pointing this up.
  8. Torch_za

    Torch_za New Member

    Fix ....

    change back-res line 356

    #Clean temp dir
    rm -rf $tmpdir/excluded
    # End of script
    log "All backup jobs done. Exiting script!"

    #Clean temp dir
    rm -rf $tmpdir/excluded
    # End of script
    log "All backup jobs done. Exiting script!"
    mail -s "Daily backup of $COMPUTER `date +'%F'`" "$email" < $tmpdir/maildata
  9. nokia80

    nokia80 Member HowtoForge Supporter


    can someone tell me how I setup cron job

    I want to do this in ISPConfig, and then at night

    with kind regards michael
  10. Torch_za

    Torch_za New Member


    You don't say for what OS: Most Linux / Unix boxes will accept the following:

    from the shell as root:
     crontab -e
    then copy and paste:
    30 1 * * *  /etc/back-res 1>/dev/null 2>/dev/null
    which is
    *     *     *   *    *        command to be executed
    -     -     -   -    -
    |     |     |   |    |
    |     |     |   |    +----- day of week (0 - 6) (Sunday=0)
    |     |     |   +------- month (1 - 12)
    |     |     +--------- day of        month (1 - 31)
    |     +----------- hour (0 - 23)
    +------------- min (0 - 59)
    So at 30 minutes past 1 every day of the month run back-res sending output and error output to the bit bucket

    To run a cronjob for hosted websites there is an option on the control panel -- sites .. cronjobs
    Last edited: May 31, 2010
  11. jmp51483

    jmp51483 New Member

    Interesting Error

    Hey g00gl3,

    I'm receiving this error with the new version of this script and just wanted to see if it's actually something I should worry about..

    /bin/tar: /adm: Cannot stat: No such file or directory
    /bin/tar: Exiting with failure status due to previous errors
    It appears as if the backup script is still taking a full backup of the ispconfig information but this error is just making a bit nervous. Is this something that I should be worried about?
  12. go0ogl3

    go0ogl3 New Member


    This error appears because you don't have a dir called "/adm" please check the 131 line of the script, variable "DIRECTORIES" and set what you want to back-up.
    In your case there is nothing to worry if the other dir's are backed up. tar just can't backup a non-existent file :)
  13. go0ogl3

    go0ogl3 New Member

    Thank you for help! I'll modify the script for public with this and other small improvements pretty soon.
  14. go0ogl3

    go0ogl3 New Member

    Attention at automated delete of files

    I've found that if you move around back-up dir the m-time can change and the script does not work as expected deleting old files, because is using the m-time to find what files to delete when there is no more space.

    There is NO problem is you don't touch those files and dirs created by back-res. But if you do be sure the m-time is corectly set.

    If you do not have set
    you can ignore this message, as the script does NOT free up space for you, if you don't have any.
  15. Torch_za

    Torch_za New Member

    more detail

    Ah well there was an interesing exercise. A week after loading and running the script - a small production server collapsed. 64 bit, Debian, ISPConfig3.0.2.1 (web and mail server), it's one of the secondary servers in a multi server set up - which also complicates things no end and alas it does NOT restore... in fact restoring rips the heart right out of the box... leaving me with a very dead box that won't even run a shell... gotta love computers....

    Now I have an old compaq rack mount G3 that I was playing with to see what the mirror options of ISPCOnfig3 did (and thats not a great deal it seems ) but - what would it take to get this box loaded whatever I can salvage from the back-res backup?
    Last edited: Jun 4, 2010
  16. go0ogl3

    go0ogl3 New Member


    you can restore the server if you have all full* files from a month (the most current, the better). Then you need all incremental files, and database dumps. You have a corrupt filesystem? If you do, make a clone of the drive onto another drive then run fsck. That way if the source drive is having bad sectors, you can recover more data.

    After recover you must create special dirs (/proc, /sys, /dev, etc) then run grub or lilo to restore the MBR of the drive, after this, if all is ok you sholud have a server like it was on the last incremental day :)

    If you have any problems, post here, I'll try to help you.
  17. Nimarda

    Nimarda New Member

    Thanks!! It works perfect! :D
  18. jmp51483

    jmp51483 New Member

    Hey g00gl3,

    Hypothetical scenario that I'd like to get your advice on if you don't mind :)

    Could I take a full backup from one server and using the same script on a different server with ispconfig installed, completely restore everything from the first server? essentially creating an exact copy of the initial?

    so Server 1 > run back res

    scp files over to Server 2

    Server 2 (exact setup as server 1) > run back res restore mode, and essentially have an exact copy?
  19. go0ogl3

    go0ogl3 New Member

    The answer is yes it's possible. Just take care and be sure you have all valuable data backed up before you begin. Try to have all required binaries (tar especially) already installed on the second server.

    I've cloned this way servers and it works, the only thing is you must pay attention to any error wich may occur and correct it.

    For first try I suggest you use a different partition for the / (root) and instruct your bootloader to dual-boot between de new and old system, this is the safest approach.

    Please write here so we can help others too.
  20. jmp51483

    jmp51483 New Member

    Currently working on it

    Hey g00gl3,

    I am in the process currently of testing out this theory, however for now on my prod boxes I'm just using the mysql replication / rsync route. I have two test boxes that I am playing around with the back-res script so I will touch base soon on if I was successful or not :)


Share This Page