ISPConfig 3 - back-res a Backup and Restore script

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

  1. Nimarda

    Nimarda New Member

    Restore db not working.


    I have Debian Lenny, and when I try to restore a database i get:
    ./ line 493: tar: No such file or directory

    I execute the backup-res script like:
    ./ db c12manit 2010-07-04

    When i execute the mysql command from de commandline:
    mysql -u***** -p**** c12manit < tar -xvjf /backups/backupvps/2010-07/db-c12manit-2010-07-04.tar.bz2

    I get the same error.
    -bash: tar: No such file or directory

    What i'm doing wrong?

    And when restoring a directory, newly created files which are not in the backup, still be there when the restoring is completed.
    Why is that?
    Last edited: Jul 4, 2010
  2. jmp51483

    jmp51483 New Member

    What happens if you untar the file yourself and try to suck in the .sql file alone via the same command? Does it give you an error?
  3. go0ogl3

    go0ogl3 Member

    You don't have the tar binary, try:
    aptitude install tar
    If it's the same system on which you have made the backups, you have uninstalled tar? Or maybe tar is not in your PATH...
    The back-res script uses which command to guess where is your tar executable...

    Hope this info wil help you..
  4. go0ogl3

    go0ogl3 Member

    New version: back-res 0.9.3


    As I encountered a 100% usage situation on a backup partition I've come across a small bug: the script can't move files (there is no space left) so I have done a small fix.

    - Modified del_old_files function to remove "/" from the $to_del variable used to delete old files
    - Removed from del_old_files function the section used to keep old databases (It's not working if there is no space left on device). Added in TODO section a reminder to improve this function.

    Allways download the latest version here:

    Old versions: - 2009-12-06 - 2010-04-18

    Note: This fix has no efect if the $del_en variable is set to "no"
    Last edited: Aug 1, 2010
  5. colo

    colo New Member

    Hi First of all excellent job I have been using this to back up for just over 1 month now and all has been well.

    I needed to use it today after I made a silly command on my vps and had to reinstall. and its really saved my bacon!

    I am also using debian lenny with ispconfig and got the same error even though tar is all ready installed. I tried editing the affected line with the full path to tar and then it failed with

    mysql: unknown option '-x'

    I have managed to restore my system by manually unpacking the .tar.bz2 and importing them into mysql manually so all is well although it would be nice to find out what the problem is and help to get it fixed.


    ./back-res dir all 2010-09-01 /

    failed with

    Extracting all dir's backup from date 2010-09-01 to /:
    Extracting full_bin-2010-09-01.tar.bz2...

    find: `//all': No such file or directory

    although it worked just fine when I restored each dir one by one


    edit: I am using 0.9.3 with the mail fix from
    Last edited: Sep 1, 2010
  6. go0ogl3

    go0ogl3 Member

    Small bug... sorry

    This is a small bug from me. I used tar not $TAR and it's possible that in your enviroment tar may not be in the PATH variable...

    The second error:
    find: `//all': No such file or directory
    seems to be because the BACKUPDIR variable is not set (notice the two slashes before all). This is the only cause I can imagine now. If you can please make some tests.

    Last edited: Sep 13, 2010
  7. go0ogl3

    go0ogl3 Member

  8. colo

    colo New Member

    Thanks go0ogl3 for the $TAR fix, the 2nd error was my own bug I had made my own amendment on my backup script and forgotten about it when it came to restoring with the original script.

    for your info I had changed
    COMPUTER=`cat /etc/hostname | awk 'NR==1{print $1}'` # name of this computer


    COMPUTER=`/bin/hostname -f | awk 'NR==1{print $1}'` # name of this computer

    hence a change in the BACKUPDIR

    sorry, my fault :p
  9. cwallace

    cwallace New Member

    I am very new to ISPconfig and have used webmin for many years. Due to the change this backup solution seems to be the only option I have. It looks like it will work wonders and do well, but my issue is that with webmin I did backups offsite over FTP.

    Can this script or the results from it be FTPed offsite? Can that be built into the script or would a secondary method need to be put in place to run after this script completes.

    Ideas and sugestions would be greatly appreciated.

  10. go0ogl3

    go0ogl3 Member

    Yes this script can be modified to transfer the backup in any way you like. After the backup job is done, we can add some lines to transfer all files over ftp, or over ssh (you can try to mount samba shares too and save there). I'm pretty busy right now but I'll consider adding this feature to the script, as soon I'll have some spare time.
  11. cwallace

    cwallace New Member

    That would be tremendously helpful...:)
  12. clttech

    clttech New Member

    Permission Denied

    I have the scrip copied to the /etc folder. I have a cron job setup for the job to run.
    40 3 * * * /etc/ 1>/dev/null 2>/dev/null

    It has not run. I logged in switched to su and ran ./ and I get Permission denied. What should the permissions be set at?
  13. wiss

    wiss Member


    Great works,

    Work fine, It's simply perfect.

    More Thx.
  14. ikrudolf

    ikrudolf Member

    Chmod it to 777
  15. go0ogl3

    go0ogl3 Member

    Did you restarted the cron daemon? Did you edited the right cron file? Some distributions use the /etc/crontab file. To be sure use
    crontab -e
    then save and restart de cron daemon.
  16. drewb0y

    drewb0y Member

    Finally setting up backup - a few errors

    when I first ran back-res to test it out I got
    /etc/back-res: line 229: /tmp/tmpbck/maildata: No such file or directory
    /etc/back-res: line 235: /tmp/tmpbck/maildata: No such file or directory
    /etc/back-res: line 220: /tmp/tmpbck/maildata: No such file or directory
    /etc/back-res: line 220: /tmp/tmpbck/maildata: No such file or directory
    /etc/back-res: line 220: /tmp/tmpbck/maildata: No such file or directory
    mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    I killed the script at this point. Checked in the /tmp/tmpbck directory and this is what I got
    gateway:/tmp/tmpbck# ls -al
    total 20
    drwxr-xr-x 2 root root 4096 2010-11-03 11:11 .
    drwxrwxrwt 5 root root 4096 2010-11-03 11:12 ..
    -rw-r--r-- 1 root root  278 2010-11-03 11:11 excluded
    -rw-r--r-- 1 root root    1 2010-11-03 11:11 full-backup_home.lck
    -rw-r--r-- 1 root root  861 2010-11-03 11:11 maildata
    Could the first error be a permissions issue?
    And as for the MySQL error, I did enter the correct password in the script. I can log in with this same password using phpmyadmin.

    I have an external USB 320GB drive mounted to /backups/external and there is a directory created for the computer name.

    Here is my variables section with the password changed and domain name.
    COMPUTER=`cat /etc/hostname | awk 'NR==1{print $1}'`    # name of this computer
    DIRECTORIES="/bin /boot /etc /home /lib /lib64 /root.
    /sbin /usr /var /www"                    # 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 *.pid *.lock *.lck"        # exclude those dir's and files
    BACKUPDIR="/backups/external/$COMPUTER"                # where to store the backups
    dbuser="root"                        # database user
    dbpassword="mypassword"                # database password
    email="[email protected]"                # 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
    I am able to login as root to mysql using the terminal command
    mysql -u root -p
    Last edited: Nov 3, 2010
  17. wiss

    wiss Member

    Great job.
    Thak you so much.

    I use it, but script not send email after complete jobs, Why?

    Have any confguration more?

  18. drewb0y

    drewb0y Member

    Solved...I think

    Solved by deleting the backup directory that I manually created instead of just letting the script do it.

    Solved: my password had some characters init that confused it I guess, it was 15 characters long with mixed Upper and lower case characters, numbers and 2 special characters, an @ and a $. Not sure which messed it up, but changing

    (single quotes on either side instead of double) seems to have fixed that.

    After that - just a few errors for the default script trying to back up non existent directories such as
    /bin/tar: /lib64: Cannot stat: No such file or directory
    Just a little more modifying and I think I am good to go.

    For go0ogl3 :

    What is your OS version? Just curious.. Thanks for the great work!
  19. go0ogl3

    go0ogl3 Member

    The script is sending mail only if you have a valid and working mail command ("mail" command is used in the script)... I hope I'll have time to enhance it.
  20. go0ogl3

    go0ogl3 Member

    The configurable section of the script it's meant to be configurable... I'll try in future versions to make it more user friendly, maybe will work by default :)

    I'm using mainly Slackware. Is the best in my oppinion.

Share This Page