ISPConfig 3 - back-res a Backup and Restore script

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

  1. nokia80

    nokia80 Member HowtoForge Supporter

    it is possible to script the backup files to be sent via ftp or ssh ???
     
  2. go0ogl3

    go0ogl3 New Member

    Short answer: Yes!

    If you want to do that without modifying the script use a mount point which is over the network, samba, nfs, ssh, ftp, etc.
    Another solution is to transfer the backed up files after the back-res script has done his job.
     
  3. (O)fer_cz

    (O)fer_cz New Member

    can i somehow backup websites separately with this great script?
     
  4. anhlqn

    anhlqn New Member

    Hi,

    I have another script with Differential backup for ISPConfig sites which I modified from oZimbraBackup script.

    It provides full and differential backup for websource, full backup for all databases, upload backup to another server via ftp.

    Download: http://www.mediafire.com/?5looz46d3ado94l
     
    Last edited: Dec 22, 2011
  5. anhlqn

    anhlqn New Member

    Hi go0ogl3,

    I have 2 ISPConfig server named server1.test.com and mirror.test.com (which mirrors ISPConfig config from server1).

    On the server1, I only backup these directories plus all databases dump:

    I tried to exclude the /usr because it take so much space.
    The ISPConfig on server1 can be successfully restored with the backup set I used.
    After restored, server1 and mirror still replicates.
    Can you check if we can safely exclude the /usr and some other directories from your backup script?

    Tks,
    Anh
     
    Last edited: Dec 22, 2011
  6. anhlqn

    anhlqn New Member

    I currently use Bacula to backup ISPconfig server. I can easily restore the ISPConfig configuration and websites without having to reconfigure the permission for sites.

    Anh
     
  7. yanger

    yanger New Member

    any instructions for this? i see Bacula on sf, but there's not a lot of documentation
     
  8. anhlqn

    anhlqn New Member

    Hi,

    Can you tell me waht you need instructions for? Using Bacula? Or what you need to backup on ISPConfig server?
     
  9. go0ogl3

    go0ogl3 New Member

    Yes. You have to enter all the websites you wish to backup in
    DIRECTORIES variable in the script. Example:

    Code:
    DIRECTORIES="/var/www/web1 /var/www/web2 /var/www/web3"
    take care with the simlinks... tar backs up only the simlink, not the target content!
     
  10. go0ogl3

    go0ogl3 New Member

    Hello,

    If you can exclude the /usr it's only your decision. If you know you don't have anythin irrecuperable you can exclude as many directories as you like. For example I personnaly, if the space is tight, back up only the /etc, /www and the databases on some servers...
    When it cames for the restore, I install the respective linux distribution, then restore the /etc /www and the databases over the fresh install.
    Take care, if you have anything changed in other directories, you'll run into problems!
     
  11. wcsing

    wcsing New Member

    Hi go0ogl3,

    please let me know the steps how to run your backup script. Sorry i never run a cron job before. do i need to rename the downloaded file to .SH? or how to put it in ISP3 > sites > corn job? Thanks
     
  12. (O)fer_cz

    (O)fer_cz New Member

    thanks for response, but its not good for auto-backup, because clients and webs changes...
     
  13. go0ogl3

    go0ogl3 New Member

    I'm using this script only from cron, so I think this is auto-backup...
     
  14. n47

    n47 New Member

    Hello

    Thank you for your script. It's working perfectly but I have a problem when I try to launch the script with CRON.

    Actually, if I run manually the script with this command

    Code:
    /etc/back-res.sh
    The script back up my datas. But if Cron launchs the script, nothing happens... I tried to see if there is errors in cron.log but I don't see them ...

    Cron is working, I do a simple test by creating a file and it's working.

    The only crontask which is not working is this one :

    10 12 * * 1 /ect/back-res.sh 1>/dev/null 2>/dev/null

    Do you have an idea ?

    Thank you.
     
  15. n47

    n47 New Member

    Problem solved, I rename /etc/back-res.sh with /etc/back-res and I replace cron task 10 12 * * 1 /ect/back-res.sh 1>/dev/null 2>/dev/null with 10 12 * * 1 /ect/back-res 1>/dev/null 2>/dev/null
     
  16. riverman

    riverman New Member HowtoForge Supporter

    Problem with / in date from ls

    Hi,

    I have problem to restore a backup. I get:

    Code:
    [root@ispconfig4 web6]# ~/back-res.sh dir all 2012-04-17
    date: invalid date `04[B]/[/B]'
    /root/back-res.sh: line 452: [: : integer expression expected
    
    The date command seems ok:
    Code:
    [root@ispconfig4 log]# date +%d
    18
    [root@ispconfig4 log]# date +%F
    2012-04-18
    [root@ispconfig4 log]# date +%Y-%m
    2012-04
    Code:
    [root@ispconfig4 web6]# ls -ctF $BACKUPDIR
    full_var-2012-04-17.tar.bz2   full_root-2012-04-17.tar.bz2   full_etc-2012-04-17.tar.bz2   full_boot-2012-04-17.tar.bz2
    full_usr-2012-04-17.tar.bz2   full_lib64-2012-04-17.tar.bz2  full_home-2012-04-17.tar.bz2  2012-04/
    full_sbin-2012-04-17.tar.bz2  full_lib-2012-04-17.tar.bz2    full_bin-2012-04-17.tar.bz2   log[B]/[/B]
    But the ls-command seems to leave a /-sign in the end of the date:

    Code:
    [root@ispconfig4 web6]# ls -ctF /bck/web6
    full_var-2012-04-17.tar.bz2   full_root-2012-04-17.tar.bz2   full_etc-2012-04-17.tar.bz2   full_boot-2012-04-17.tar.bz2
    full_usr-2012-04-17.tar.bz2   full_lib64-2012-04-17.tar.bz2  full_home-2012-04-17.tar.bz2  2012-04/
    full_sbin-2012-04-17.tar.bz2  full_lib-2012-04-17.tar.bz2    full_bin-2012-04-17.tar.bz2   log[B]/[/B]
    Code:
    [root@ispconfig4 web6]# ls -ctF /bck/web6 | grep -v ^log/
    full_var-2012-04-17.tar.bz2
    full_usr-2012-04-17.tar.bz2
    full_sbin-2012-04-17.tar.bz2
    full_root-2012-04-17.tar.bz2
    full_lib64-2012-04-17.tar.bz2
    full_lib-2012-04-17.tar.bz2
    full_etc-2012-04-17.tar.bz2
    full_home-2012-04-17.tar.bz2
    full_bin-2012-04-17.tar.bz2
    full_boot-2012-04-17.tar.bz2
    2012-04[B]/[/B]
    Code:
    [root@ispconfig4 web6]# ls -ctF /bck/web6  | grep -v ^log/ | tail -n 1
    2012-04[B]/[/B]
    Code:
    [root@ispconfig4 web6]# ls -ctF /bck/web6  | grep -v ^log/ | tail -n 1 | cut -d "-" -f 2
    04[B]/[/B]
    The ls command ends a directory with / and therefor will the date be wrong...

    Dist: Centos 6.2 64-bit

    Code:
    Variables section
    -----------------
    COMPUTER="web6"
    DIRECTORIES="/bin /boot /etc /home /lib /lib64 /root
    /sbin /usr /var"                    # directories to backup
    EXCLUDED="/bck /tmp /dev /proc /sys /srv /media
    /var/adm /var/cache /var/lib/mysql
    /var/run /var/lock /lib/init/rw /var/tmp
    /var/log/verlihub /var/lib/amavis /var/amavis /var/spool/postfix/p*
    /var/spool/postfix/var
    /var/www/clients/client2/web5/webdav/data
    /var/named/chroot/proc *.pid *.lock *.lck"        # exclude those dir's and files
    BACKUPDIR="/bck/$COMPUTER"                # where to store the backups
    dbuser="root"                        # database user
    dbpassword="password"                # database password
    email="mans.aman@riverman.com"                # mail for the responsible person
    TAR=`which tar`                        # name and location of tar
    ARG="-cjpSPf"        #sparse                # tar arguments P = removed /.
    EARG="-xjpf"                        # tar extract arguments P = removed /
    tmpdir="/tmp/tmpbck"                    # temp dir for database dump and other stuff
    del_en="yes"                        # Enable delete of files if used space percent > than $maxp (yes or anything else)
    maxp="85"                        # Max percent of used space before start of delete
    hm="2359"                        # last minute of the day = last minute of the restored backup of the day restored
    Any ideas how to fix this?

    /Måns
     
  17. lobius

    lobius Member HowtoForge Supporter

    Code:
    note     : Table does not support optimize, doing recreate + analyze instead
    roundcube.users
    note     : Table does not support optimize, doing recreate + analyze instead
    mysqldump: Got error: 1044: Access denied for user 'root'@'localhost' to database 'information_schema' when using LOCK TABLES
    


    Are my tables being backed up anyway?

    There is no problem with root@localhost.

    Why does that message show up?

    Excellent script. :) Thanks.
     
  18. till

    till Super Moderator Staff Member ISPConfig Developer

    The error messages are ok. Not every mysql table type can be optimized and the information_schema database is a internal mysql database structure, so you can not back that up and it does not need to be included in the backup.
     
  19. riverman

    riverman New Member HowtoForge Supporter

    Needed changes on Centos 6.2 64-bit

    So I changed the lines beginning with year=, md= and day= so they are like this:
    Code:
    year=`ls -ct $BACKUPDIR | grep -v ^log  | tail -n 1 | cut -d "-" -f 1`
    md=`ls -ct $BACKUPDIR | grep -v ^log | tail -n 1 | cut -d "-" -f 2`
    day=`ls -ct $BACKUPDIR | grep -v ^log | tail -n 1 | cut -d "-" -f 3 | cut -d "." -f 1`
    
    I also had to make sure the tmpdir= variable was pointing to a valid directory which it didn't on Centos 6.2 64-bit.

    Now everything works great! I was backing up a production mail server because we needed to move to a new server.
     
  20. lobius

    lobius Member HowtoForge Supporter

    Code:
    /bin/tar: /var/www/roundcube/logs/errors: file changed as we read it
    /bin/tar: /var/spool/postfix/dev/log: socket ignored
    /bin/tar: /www: Cannot stat: No such file or directory
    /bin/tar: Exiting with failure status due to previous errors
    
    Looks like the databases backed up just fine.

    I understand the roundcube problem. I attempted to back up in the middle of the day and something changed.

    Not sure about the /www error. Should I change that to /var/www or remove it from the script?

     

Share This Page