ISPConfig 3 - back-res a Backup and Restore script

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

  1. danjde

    danjde New Member

    Hi Friends!
    Running back-res, after db backup, obtain this warnings/errors:

    /sbin/back-res: line 407: [: too arguments
    /bin/tar: /www: function "stat" failed: File or directory does not exist
    /bin/tar: Exit with failure status based on previous errors

    This is the part of the script concerned:

    for i in `echo $DIRECTORIES` ; do
        XX=`echo $i | awk '{gsub("/", "_", $0); print}'`
        YX=`echo $i | awk '{print $1}'`
        fb=`ls $BACKUPDIR | grep ^full$XX-`
            if [ -z $fb ] ; then
                log "No full backup found for $YX. Full backup now!"
                echo > $tmpdir/full-backup$XX.lck
                $TAR $ARG $BACKUPDIR/full$XX-$FDATE.tar.bz2 $YX -X $tmpdir/excluded
                log "Backup of $YX done."

    the 407 line is this:

    if [ -z $fb ] ; then
    Why is this happening? Do I have something wrong?

    Many many thanks!
  2. Geekteq

    Geekteq New Member

    If you had read the thread a few back you'd find the same already discussed.
    Look here #233
  3. danjde

    danjde New Member

    Thanks Geekteq, I didn't see the previous post :confused:
    Now, with the changes, it works fine!
    Strange that the developer has not yet corrected the bug! I'll try to report it to him.
  4. danjde

    danjde New Member

    Hi Friends,
    after to have corrected the bug described above,
    today (at the first one month day backup time) just a few minutes after starting the "back-res" script the MySQL server hangs:

    service mysql stop
    service mysql start
    Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
    systemctl status mysql.service
    ● mysql.service - LSB: Start and stop the mysql database server daemon
       Loaded: loaded (/etc/init.d/mysql)
       Active: failed (Result: exit-code) since lun 2018-01-01 15:49:30 CET; 10s ago
      Process: 18210 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
      Process: 18261 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
    gen 01 15:49:30 server /etc/init.d/mysql[19100]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
    gen 01 15:49:30 server mysql[18261]: Starting MySQL database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!
    gen 01 15:49:30 server systemd[1]: mysql.service: control process exited, code=exited status=1
    gen 01 15:49:30 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
    gen 01 15:49:30 server systemd[1]: Unit mysql.service entered failed state.
    Then reloading again the MySQL server, everything is broken down correctly.

    Has anyone of you encountered similar problems?

    Many thanks!

  5. yodaofborg

    yodaofborg New Member

    Still a great script after all this time, the only problem I have with it is it does not exclude directories from /var with the latest update, even if specified. log, spool, run, are all added due to the script recursive adding them in the # Add /var excluding subdirectories /var/www and /var/vmail to DIRECTORIES section. (debian 9.4 with version="0.9.6 from 2014-02-04")

    Still, great way of keeping daily backups of my sites, I just hate to waste disk space on things I do not need backed up :)


    Just fixed this myself, the tar command in debian 9 needs the -X option set before telling it what to backup, or it will include the files it has been told to (expected behaviour for GNU tar, since forever?), so changing the lines (around line 407) from:
    $TAR $ARG $BACKUPDIR/full$XX-$FDATE.tar.bz2 $YX -X $tmpdir/excluded
    $TAR $ARG $BACKUPDIR/full$XX-$FDATE.tar.bz2 $YX -X $tmpdir/excluded
    $TAR $NEWER $ARG $BACKUPDIR/$MDATE/i$XX-$FDATE.tar.bz2 $YX -X $tmpdir/excluded 
    $TAR $ARG $BACKUPDIR/full$XX-$FDATE.tar.bz2 -X $tmpdir/excluded $YX
    $TAR $ARG $BACKUPDIR/full$XX-$FDATE.tar.bz2 -X $tmpdir/excluded $YX
    $TAR $NEWER $ARG $BACKUPDIR/$MDATE/i$XX-$FDATE.tar.bz2 -X $tmpdir/excluded $YX
    fixed the issue.
    Last edited: May 18, 2018
    30uke, Gruppo Pegaso and ahrasis like this.
  6. toyinal

    toyinal Member

    I'm unable to restore /var directory from a date 2018-08-29 Im using back-res version 0.9.6 The program will all show blank when restoring but no files are restored. Also restoring a specific /var/vmail/xxxxx.tld from a particular date does not work. I know there is a backup file .tar.bz2 for that date and for that specific account, i've checked. Full backup restore works. I know that specific date restore works before the update to version 0.9.6

  7. dejvic

    dejvic New Member

    please have you got anyone right script for backup and restore ispconfig3 ver. to last version?
  8. 30uke

    30uke Member HowtoForge Supporter

    Thanks for sharing this as it also fixes the same issue for me.

    I did run a backup task and I noticed the following output.

    [email protected]:/# /opt/back-res/back-res
    /opt/back-res/back-res: line 290: /tmp/tmpbck/maildata: No such file or directory
    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
    mysqldump: Got error: 1142: "SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts'" when using LOCK TABLES
    /bin/tar: /www: Cannot stat: No such file or directory
    /bin/tar: Exiting with failure status due to previous errors
    /bin/tar: /var/lib/php7.0-fpm/web2.sock: socket ignored
    /bin/tar: /var/log/ file changed as we read it
    I am a little bit worried about the databases 'information_schema' and 'performance_schema'. The dump does not represent the current database. I am not sure if this would be a real problem as these are system databases and not the databases required/used by the websites and ISPconfig. Would it be an idea to leave these databases out of the backup?

    I don't know what to think about the 'tar cannot stat' error. I don't believe the "/www" is required. It did not exist in the root of my system. I just did create it manually and put a place holder file - just to satisfy tar.

    Overall it looks like that the script just works fine. At least I have a bunch of usable

    And I did notice this file:
    [email protected]:/# cat /tmp/tmpbck/maildata
    2019-01-09 22:29:40 - back-res - Temp dir /tmp/tmpbck created
    2019-01-09 22:39:02 - back-res - All backup jobs done. Exiting script!
    But I did not receive any e-mail. Couldn't find an error in the script itself. I am able to send e-mails manually by reproducing the command from the script myself.
  9. danjde

    danjde New Member

    You can exclude "/www" from initial script options, useful if you are using /var/www Instead to /www

    I think yes, could be fine to exclude 'information_schema' and 'performance_schema', as suggested here:

    No, the best way as suggested above, is exclude it form options script ;-)

    I use these parameters for crontab:

    0 0 1 * * /sbin/back-res 2>&1 | mail -s "backup-all-files" [email protected]_domain
    ahrasis likes this.
  10. burlyhousetech

    burlyhousetech Member HowtoForge Supporter

    This script is so helpful - thank you for your contribution to the ISPConfig community! Gratitude!

    In my hosting environment some users have very large databases (multiple GB-TB) and should be excluded from the backup. Has anyone extended this script to filter specific databases from the backup? Looking for something akin to what `EXCLUDED` config provides, contextual to MySQL database rather than filesystem.
  11. danjde

    danjde New Member

    Hi Friends!

    I'm try to use back-res on Debian 10, but "tar" seems that is having some problems during backup:

    /usr/bin/tar: The following options were used after any non-optional arguments in archive create or update mode.  These options are positional and affect only arguments that follow them.  Please, rearrange them properly.
    /usr/bin/tar: --exclude-from "/tmp/tmpbck/excluded" has no effect
    /usr/bin/tar: Failed exit based on previous errors
    The problem seems depends from the position where the exclusion command is located:
    Ithink so shoud be fine, test please!

    $TAR -X $tmpdir/excluded $ARG $BACKUPDIR/full$XX-$FDATE.tar.bz2 $YX


Share This Page