Welcome to Centmin Mod Community
Become a Member

Beta Branch Nginx binary + modules backup/restore - nginx-binary-backup.sh

Discussion in 'Beta release code' started by eva2000, Aug 17, 2018.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Working on a new tools/nginx-binary-backup.sh script for Centmin Mod 123.09beta01 which allows you to backup only the nginx binary and nginx dynamic modules and then restore those backed up nginx binary and nginx dynamic modules. The backup and restores are meant for the same server usage rather as Nginx is usually compiled against the server's specific cpu module for performance optimisations. You could in theory use it on other servers if you have the exact same cpu model as other server.

    This is useful:
    • If you're testing several nginx compiled configurations i.e. different GCC/Clang versions or LibreSSL or OpenSSL versions and want to be able to back those up and restore them without needing to do a centmin.sh menu option 4 recompile.
    • On exact cpu model systems, you can compile Nginx on one server (staging/test/dev) and run nginx-binary-backup.sh and then move the backed up files to the other exact cpu model system (production/live) at same backup location /home/backup-nginxbin and use the script to restore on production live system.

    Script Usage Options



    3 command options available for backup, list and restore

    Code (Text):
    ./nginx-binary-backup.sh
    
    ./nginx-binary-backup.sh {backup|list|restore}
    


    Backup



    Backups are saved into directory at /home/backup-nginxbin into labeled directories according to nginx version, compiler version, crypto library version and date timestamp

    The following are backed up
    • /usr/local/sbin/nginx - nginx binary itself
    • /usr/local/nginx/modules - nginx dynamic modules
    • /usr/local/nginx/conf/dynamic-modules-includes.conf - nginx dynamic modules included include file which is included in /usr/local/nginx/conf/dynamic-modules.conf so you can set you own loaded dynamic nginx modules which persist on nginx upgrades
    • /usr/local/nginx/conf/dynamic-modules.conf - nginx dynamic modules include file which loads the nginx dynamic modules automatically based on nginx upgrade configuration you select
    Code (Text):
    ./nginx-binary-backup.sh backup
    

    Code (Text):
    ./nginx-binary-backup.sh backup
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814:
    total 20K
    drwxr-xr-x.  4 root root 4.0K Aug 17 06:18 .
    drwxr-xr-x. 10 root root 4.0K Aug 17 06:18 ..
    drwxr-xr-x.  2 root root 4.0K Aug 17 06:18 bin
    -rw-r--r--.  1 root root  562 Aug 17 05:32 dynamic-modules.conf
    -rw-r--r--.  1 root root    0 Aug 12 00:24 dynamic-modules-includes.conf
    drwxr-xr-x.  2 root root 4.0K Aug 17 05:41 modules
    
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814/bin:
    total 4.2M
    drwxr-xr-x. 2 root root 4.0K Aug 17 06:18 .
    drwxr-xr-x. 4 root root 4.0K Aug 17 06:18 ..
    -rwxr-xr-x. 1 root root 4.2M Aug 17 05:41 nginx
    
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814/modules:
    total 856K
    drwxr-xr-x. 2 root root 4.0K Aug 17 05:41 .
    drwxr-xr-x. 4 root root 4.0K Aug 17 06:18 ..
    -rwxr-xr-x. 1 root root  23K Aug 17 05:41 ndk_http_module.so
    -rwxr-xr-x. 1 root root  63K Aug 17 05:41 ngx_http_echo_module.so
    -rwxr-xr-x. 1 root root  63K Aug 12 00:32 ngx_http_echo_module.so.old
    -rwxr-xr-x. 1 root root  29K Aug 17 05:41 ngx_http_fancyindex_module.so
    -rwxr-xr-x. 1 root root  29K Aug 12 00:32 ngx_http_fancyindex_module.so.old
    -rwxr-xr-x. 1 root root  42K Aug 17 05:41 ngx_http_headers_more_filter_module.so
    -rwxr-xr-x. 1 root root  42K Aug 12 00:32 ngx_http_headers_more_filter_module.so.old
    -rwxr-xr-x. 1 root root  28K Aug 17 05:41 ngx_http_image_filter_module.so
    -rwxr-xr-x. 1 root root  28K Aug 12 00:32 ngx_http_image_filter_module.so.old
    -rwxr-xr-x. 1 root root  36K Aug 17 05:41 ngx_http_set_misc_module.so
    -rwxr-xr-x. 1 root root  36K Aug 12 00:32 ngx_http_set_misc_module.so.old
    -rwxr-xr-x. 1 root root 208K Aug 17 05:41 ngx_stream_module.so
    -rwxr-xr-x. 1 root root 208K Aug 12 00:32 ngx_stream_module.so.old
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814
    

    So backed up nginx binary would be at /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814/bin/nginx so you could run the nginx binary itself manually too i.e. check it's version

    Backup List



    List all backups contained in backup directory at /home/backup-nginxbin

    Code (Text):
    ./nginx-binary-backup.sh list
    

    Code (Text):
    ./nginx-binary-backup.sh list
    --------------------------------------------------------
    Listing of available Nginx binary/module backups
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060640
    /home/backup-nginxbin/1.15.2-gcc-7.3.1-20180303-openssl-1.1.0h-170818-052446
    /home/backup-nginxbin/1.15.3-clang-5.0.1-tags-RELEASE_501-final-openssl-1.1.0i-170818-070342
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-055701
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-062029
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-055728
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060150
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    --------------------------------------------------------
    

    So if you backed up Nginx 1.15.3 with Clang 5.0.1 compiler and OpenSSL 1.1.0i, you can check the binary backed up according to list output at /home/backup-nginxbin/1.15.3-clang-5.0.1-tags-RELEASE_501-final-openssl-1.1.0i-170818-070342/bin/nginx

    Restore Backup Interactive



    Interactive restores will list the available backup directories and then prompt you to enter the full path to backup you want to restore. In this example, I want to restore /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221

    Prior to restore, another backup is automatically made of existing live files just in case.

    Code (Text):
    ./nginx-binary-backup.sh restore
    

    Code (Text):
    ./nginx-binary-backup.sh restore
    --------------------------------------------------------
    Restore Nginx binary/module from backups
    --------------------------------------------------------
    --------------------------------------------------------
    Listing of available Nginx binary/module backups
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060640
    /home/backup-nginxbin/1.15.2-gcc-7.3.1-20180303-openssl-1.1.0h-170818-052446
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-055701
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-055728
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060150
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    --------------------------------------------------------
    
    --------------------------------------------------------
    Enter full path of backup to restore: /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    
    You entered /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    
    Is this correct ? [y/n] y
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-062029
    --------------------------------------------------------
    
    restoring...
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/bin/nginx /usr/local/sbin/nginx
    -rwxr-xr-x. 1 root root 4.2M Aug 17 05:41 /usr/local/sbin/nginx
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/modules /usr/local/nginx
    total 856K
    drwxr-xr-x.  2 root root 4.0K Aug 17 05:41 .
    drwxr-xr-x. 11 root root 4.0K Aug 17 06:20 ..
    -rwxr-xr-x.  1 root root  23K Aug 17 05:41 ndk_http_module.so
    -rwxr-xr-x.  1 root root  63K Aug 17 05:41 ngx_http_echo_module.so
    -rwxr-xr-x.  1 root root  63K Aug 12 00:32 ngx_http_echo_module.so.old
    -rwxr-xr-x.  1 root root  29K Aug 17 05:41 ngx_http_fancyindex_module.so
    -rwxr-xr-x.  1 root root  29K Aug 12 00:32 ngx_http_fancyindex_module.so.old
    -rwxr-xr-x.  1 root root  42K Aug 17 05:41 ngx_http_headers_more_filter_module.so
    -rwxr-xr-x.  1 root root  42K Aug 12 00:32 ngx_http_headers_more_filter_module.so.old
    -rwxr-xr-x.  1 root root  28K Aug 17 05:41 ngx_http_image_filter_module.so
    -rwxr-xr-x.  1 root root  28K Aug 12 00:32 ngx_http_image_filter_module.so.old
    -rwxr-xr-x.  1 root root  36K Aug 17 05:41 ngx_http_set_misc_module.so
    -rwxr-xr-x.  1 root root  36K Aug 12 00:32 ngx_http_set_misc_module.so.old
    -rwxr-xr-x.  1 root root 208K Aug 17 05:41 ngx_stream_module.so
    -rwxr-xr-x.  1 root root 208K Aug 12 00:32 ngx_stream_module.so.old
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/dynamic-modules.conf /usr/local/nginx/conf/dynamic-modules.conf
    -rw-r--r--. 1 root root 562 Aug 17 05:32 /usr/local/nginx/conf/dynamic-modules.conf
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/dynamic-modules-includes.conf /usr/local/nginx/conf/dynamic-modules-includes.conf
    -rw-r--r--. 1 root root 0 Aug 12 00:24 /usr/local/nginx/conf/dynamic-modules-includes.conf
    --------------------------------------------------------
    Restored Nginx binary/module from
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    --------------------------------------------------------
    nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
    ngxreload
    Reloading nginx configuration (via systemctl):             [  OK  ]
    --------------------------------------------------------
    



    Restore Backup non-Interactive



    You can also do restores without any user input required by passing the full path to a known nginx on the restore command line i.e. /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221. This is useful if you want to script and automate nginx backup and restores for benchmarking and testing etc.

    Prior to restore, another backup is automatically made of existing live files just in case.

    Code (Text):
    ./nginx-binary-backup.sh restore /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    

    Code (Text):
    ./nginx-binary-backup.sh restore /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    --------------------------------------------------------
    Restore Nginx binary/module from backups
    --------------------------------------------------------
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    --------------------------------------------------------
    
    restoring...
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/bin/nginx /usr/local/sbin/nginx
    -rwxr-xr-x. 1 root root 4.2M Aug 17 05:41 /usr/local/sbin/nginx
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/modules /usr/local/nginx
    total 856K
    drwxr-xr-x.  2 root root 4.0K Aug 17 05:41 .
    drwxr-xr-x. 11 root root 4.0K Aug 17 06:10 ..
    -rwxr-xr-x.  1 root root  23K Aug 17 05:41 ndk_http_module.so
    -rwxr-xr-x.  1 root root  63K Aug 17 05:41 ngx_http_echo_module.so
    -rwxr-xr-x.  1 root root  63K Aug 12 00:32 ngx_http_echo_module.so.old
    -rwxr-xr-x.  1 root root  29K Aug 17 05:41 ngx_http_fancyindex_module.so
    -rwxr-xr-x.  1 root root  29K Aug 12 00:32 ngx_http_fancyindex_module.so.old
    -rwxr-xr-x.  1 root root  42K Aug 17 05:41 ngx_http_headers_more_filter_module.so
    -rwxr-xr-x.  1 root root  42K Aug 12 00:32 ngx_http_headers_more_filter_module.so.old
    -rwxr-xr-x.  1 root root  28K Aug 17 05:41 ngx_http_image_filter_module.so
    -rwxr-xr-x.  1 root root  28K Aug 12 00:32 ngx_http_image_filter_module.so.old
    -rwxr-xr-x.  1 root root  36K Aug 17 05:41 ngx_http_set_misc_module.so
    -rwxr-xr-x.  1 root root  36K Aug 12 00:32 ngx_http_set_misc_module.so.old
    -rwxr-xr-x.  1 root root 208K Aug 17 05:41 ngx_stream_module.so
    -rwxr-xr-x.  1 root root 208K Aug 12 00:32 ngx_stream_module.so.old
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/dynamic-modules.conf /usr/local/nginx/conf/dynamic-modules.conf
    -rw-r--r--. 1 root root 562 Aug 17 05:32 /usr/local/nginx/conf/dynamic-modules.conf
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221/dynamic-modules-includes.conf /usr/local/nginx/conf/dynamic-modules-includes.conf
    -rw-r--r--. 1 root root 0 Aug 12 00:24 /usr/local/nginx/conf/dynamic-modules-includes.conf
    --------------------------------------------------------
    Restored Nginx binary/module from
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    --------------------------------------------------------
    nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
    ngxreload
    Reloading nginx configuration (via systemctl):             [  OK  ]
    --------------------------------------------------------
    



     
    Last edited: Aug 18, 2018
  2. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Example where current Nginx version is 1.15.3 compiled using Clang 5.0.1 with OpenSSL 1.1.0i
    Available backups listing
    Code (Text):
    tools/nginx-binary-backup.sh list
    --------------------------------------------------------
    Listing of available Nginx binary/module backups
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060640
    /home/backup-nginxbin/1.15.2-gcc-7.3.1-20180303-openssl-1.1.0h-170818-052446
    /home/backup-nginxbin/1.15.3-clang-5.0.1-tags-RELEASE_501-final-openssl-1.1.0i-170818-070342
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-055701
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060221
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-062029
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-055728
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-060150
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061814
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    

    I'll restore Nginx 1.15.3 compiled using GCC 7.3.1 with OpenSSL 1.1.0i at /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    Code (Text):
    tools/nginx-binary-backup.sh restore /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    

    output from restore
    Code (Text):
    tools/nginx-binary-backup.sh restore /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    --------------------------------------------------------
    Restore Nginx binary/module from backups
    --------------------------------------------------------
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.3-clang-5.0.1-tags-RELEASE_501-final-openssl-1.1.0i-170818-080427
    --------------------------------------------------------
    
    restoring...
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050/bin/nginx /usr/local/sbin/nginx
    -rwxr-xr-x. 1 root root 4.2M Aug 17 05:41 /usr/local/sbin/nginx
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050/modules /usr/local/nginx
    total 856K
    drwxr-xr-x.  2 root root 4.0K Aug 17 05:41 .
    drwxr-xr-x. 11 root root 4.0K Aug 17 08:04 ..
    -rwxr-xr-x.  1 root root  23K Aug 17 05:41 ndk_http_module.so
    -rwxr-xr-x.  1 root root  63K Aug 17 05:41 ngx_http_echo_module.so
    -rwxr-xr-x.  1 root root  63K Aug 12 00:32 ngx_http_echo_module.so.old
    -rwxr-xr-x.  1 root root  29K Aug 17 05:41 ngx_http_fancyindex_module.so
    -rwxr-xr-x.  1 root root  29K Aug 12 00:32 ngx_http_fancyindex_module.so.old
    -rwxr-xr-x.  1 root root  42K Aug 17 05:41 ngx_http_headers_more_filter_module.so
    -rwxr-xr-x.  1 root root  42K Aug 12 00:32 ngx_http_headers_more_filter_module.so.old
    -rwxr-xr-x.  1 root root  28K Aug 17 05:41 ngx_http_image_filter_module.so
    -rwxr-xr-x.  1 root root  28K Aug 12 00:32 ngx_http_image_filter_module.so.old
    -rwxr-xr-x.  1 root root  36K Aug 17 05:41 ngx_http_set_misc_module.so
    -rwxr-xr-x.  1 root root  36K Aug 12 00:32 ngx_http_set_misc_module.so.old
    -rwxr-xr-x.  1 root root 208K Aug 17 05:41 ngx_stream_module.so
    -rwxr-xr-x.  1 root root 208K Aug 12 00:32 ngx_stream_module.so.old
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050/dynamic-modules.conf /usr/local/nginx/conf/dynamic-modules.conf
    -rw-r--r--. 1 root root 562 Aug 17 05:32 /usr/local/nginx/conf/dynamic-modules.conf
    
    cp -af /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050/dynamic-modules-includes.conf /usr/local/nginx/conf/dynamic-modules-includes.conf
    -rw-r--r--. 1 root root 0 Aug 12 00:24 /usr/local/nginx/conf/dynamic-modules-includes.conf
    --------------------------------------------------------
    Restored Nginx binary/module from
    /home/backup-nginxbin/1.15.3-gcc-7.3.1-20180303-openssl-1.1.0i-170818-061050
    --------------------------------------------------------
    nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
    ngxreload
    Reloading nginx configuration (via systemctl):             [  OK  ]
    --------------------------------------------------------
    

    Now double check current Nginx version is now the restored version
     
  3. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Updated to support Nginx + BoringSSL tagged backup labels

    Code (Text):
    ./nginx-binary-backup.sh backup                                                    
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-boringssl-190818-020957:
    total 12K
    drwxr-xr-x   4 root root   97 Aug 19 02:09 .
    drwxr-xr-x  11 root root 4.0K Aug 19 02:09 ..
    drwxr-xr-x   2 root root   19 Aug 19 02:09 bin
    -rw-r--r--   1 root root  674 Aug 19 00:06 dynamic-modules.conf
    -rw-r--r--.  1 root root    0 Jul 17  2017 dynamic-modules-includes.conf
    drwxr-xr-x.  2 root root 4.0K Aug 19 00:07 modules
    
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-boringssl-190818-020957/bin:
    total 1.3M
    drwxr-xr-x 2 root root   19 Aug 19 02:09 .
    drwxr-xr-x 4 root root   97 Aug 19 02:09 ..
    -rwxr-xr-x 1 root root 1.3M Aug 19 00:07 nginx
    
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-boringssl-190818-020957/modules:
    total 8.3M
    drwxr-xr-x. 2 root root 4.0K Aug 19 00:07 .
    drwxr-xr-x  4 root root   97 Aug 19 02:09 ..
    -rwxr-xr-x  1 root root 101K Aug 19 00:07 ndk_http_module.so
    -rwxr-xr-x  1 root root 151K Aug 18 23:59 ndk_http_module.so.old
    -rwxr-xr-x  1 root root  94K Aug 19 00:07 ngx_http_brotli_filter_module.so
    -rwxr-xr-x  1 root root 144K Aug 18 23:59 ngx_http_brotli_filter_module.so.old
    -rwxr-xr-x  1 root root  88K Aug 19 00:07 ngx_http_brotli_static_module.so
    -rwxr-xr-x  1 root root 138K Aug 18 23:59 ngx_http_brotli_static_module.so.old
    -rwxr-xr-x  1 root root 518K Aug 19 00:07 ngx_http_echo_module.so
    -rwxr-xr-x  1 root root 787K Aug 18 23:59 ngx_http_echo_module.so.old
    -rwxr-xr-x  1 root root 111K Aug 19 00:07 ngx_http_fancyindex_module.so
    -rwxr-xr-x  1 root root 161K Aug 18 23:59 ngx_http_fancyindex_module.so.old
    -rwxr-xr-x  1 root root 216K Aug 19 00:07 ngx_http_headers_more_filter_module.so
    -rwxr-xr-x  1 root root 326K Aug 18 23:59 ngx_http_headers_more_filter_module.so.old
    -rwxr-xr-x  1 root root 105K Aug 19 00:07 ngx_http_image_filter_module.so
    -rwxr-xr-x  1 root root 155K Aug 18 23:59 ngx_http_image_filter_module.so.old
    -rwxr-xr-x  1 root root  35K Jun 22 23:32 ngx_http_modsecurity_module.so
    -rwxr-xr-x  1 root root 625K Aug 19 00:07 ngx_http_set_misc_module.so
    -rwxr-xr-x  1 root root 974K Aug 18 23:59 ngx_http_set_misc_module.so.old
    -rwxr-xr-x  1 root root 665K May 10 00:33 ngx_http_vhost_traffic_status_module.so
    -rwxr-xr-x  1 root root 897K May 10 00:24 ngx_http_vhost_traffic_status_module.so.old
    -rwxr-xr-x  1 root root 788K Aug 19 00:07 ngx_stream_module.so
    -rwxr-xr-x  1 root root 1.3M Aug 18 23:59 ngx_stream_module.so.old
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-boringssl-190818-020957
    --------------------------------------------------------
    

    Code (Text):
    ./nginx-binary-backup.sh list
    --------------------------------------------------------
    Listing of available Nginx binary/module backups
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-044904
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-050330
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-051015
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-051043
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-184702
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-boringssl-190818-020809
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-boringssl-190818-020957
    

    backed up binary
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Example of backed up binary's file and directory structure for /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-184702

    Code (Text):
    tree -A /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-184702
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180810-openssl-1.1.0i-170818-184702
    +-- bin
    |   +-- nginx
    +-- dynamic-modules.conf
    +-- dynamic-modules-includes.conf
    +-- modules
        +-- ndk_http_module.so
        +-- ndk_http_module.so.old
        +-- ngx_http_brotli_filter_module.so
        +-- ngx_http_brotli_filter_module.so.old
        +-- ngx_http_brotli_static_module.so
        +-- ngx_http_brotli_static_module.so.old
        +-- ngx_http_echo_module.so
        +-- ngx_http_echo_module.so.old
        +-- ngx_http_fancyindex_module.so
        +-- ngx_http_fancyindex_module.so.old
        +-- ngx_http_headers_more_filter_module.so
        +-- ngx_http_headers_more_filter_module.so.old
        +-- ngx_http_image_filter_module.so
        +-- ngx_http_image_filter_module.so.old
        +-- ngx_http_modsecurity_module.so
        +-- ngx_http_set_misc_module.so
        +-- ngx_http_set_misc_module.so.old
        +-- ngx_http_vhost_traffic_status_module.so
        +-- ngx_http_vhost_traffic_status_module.so.old
        +-- ngx_stream_module.so
        +-- ngx_stream_module.so.old
    
    2 directories, 24 files
    

    The dynamic nginx modules ending in *.so.old are the previous version of the models from previous centmin.sh menu option 4 runs so I will probably update nginx-binary-backup.sh to remove these *.so.old from backup process in future
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Latest tools/nginx-binary-backup.sh script has cleaner backup display for backed up directory and files
    Code (Text):
    ./nginx-binary-backup.sh backup                             
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    backup started...
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-openssl-1.1.1-pre9-dev-190818-203420
    +-- bin
    |   +-- nginx
    +-- dynamic-modules.conf
    +-- dynamic-modules-includes.conf
    +-- modules
        +-- ndk_http_module.so
        +-- ngx_http_brotli_filter_module.so
        +-- ngx_http_brotli_static_module.so
        +-- ngx_http_echo_module.so
        +-- ngx_http_fancyindex_module.so
        +-- ngx_http_headers_more_filter_module.so
        +-- ngx_http_image_filter_module.so
        +-- ngx_http_modsecurity_module.so
        +-- ngx_http_set_misc_module.so
        +-- ngx_http_vhost_traffic_status_module.so
        +-- ngx_stream_module.so
    
    2 directories, 14 files
    backup finished...
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.3-gcc-8.2.1-20180817-openssl-1.1.1-pre9-dev-190818-203420
    --------------------------------------------------------
    
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Updated tools/nginx-binary-backup.sh to detect and label nginx binaries which have been compiled with Nginx debug mode (--with-debug)
    Example backup for nginx binary with debug mode enabled
    Code (Text):
    ./nginx-binary-backup.sh backup
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    backup started...
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.5-gcc-7.3.1-20180303-openssl-1.1.1-281018-154246-debug
    +-- bin
    |   +-- nginx
    +-- dynamic-modules.conf
    +-- dynamic-modules-includes.conf
    +-- modules
        +-- ndk_http_module.so
        +-- ngx_http_brotli_filter_module.so
        +-- ngx_http_brotli_static_module.so
        +-- ngx_http_echo_module.so
        +-- ngx_http_fancyindex_module.so
        +-- ngx_http_headers_more_filter_module.so
        +-- ngx_http_image_filter_module.so
        +-- ngx_http_set_misc_module.so
        +-- ngx_stream_module.so
    
    2 directories, 12 files
    backup finished...
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.5-gcc-7.3.1-20180303-openssl-1.1.1-281018-154246-debug
    --------------------------------------------------------
    

    This means you can compile a debug build of Nginx, run tools/nginx-binary-backup.sh to back it up and then restore a previous backup nginx build without debug mode for 24/7 live production use. If you need to debug nginx, instead of recompiling, you just restore a backed up copy of nginx with debug built.

    List of backups made that you can restore switch to
    Code (Text):
    ./nginx-binary-backup.sh list
    --------------------------------------------------------
    Listing of available Nginx binary/module backups
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.5-gcc-7.3.1-20180303-openssl-1.1.1-281018-153813
    /home/backup-nginxbin/1.15.5-gcc-7.3.1-20180303-openssl-1.1.1-281018-153557
    /home/backup-nginxbin/1.15.5-gcc-7.3.1-20180303-openssl-1.1.1-281018-154246-debug
    --------------------------------------------------------
    
     
  7. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Updated 123.09beta01 to add label for backup names to differentiate between Cloudflare HPACK patch/non-patch and Cloudflare Zlib/std Zlib built Nginx binaries
    Code (Text):
    ./nginx-binary-backup.sh backup
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    backup started...
    --------------------------------------------------------
    /home/backup-nginxbin/1.15.7-gcc-7.3.1-20180303-openssl-1.1.1a-071218-221102-hpack-cfzlib
    +-- bin
    |   +-- nginx
    +-- dynamic-modules.conf
    +-- dynamic-modules-includes.conf
    +-- modules
        +-- ndk_http_module.so
        +-- ngx_http_brotli_filter_module.so
        +-- ngx_http_brotli_static_module.so
        +-- ngx_http_echo_module.so
        +-- ngx_http_fancyindex_module.so
        +-- ngx_http_geoip2_module.so
        +-- ngx_http_headers_more_filter_module.so
        +-- ngx_http_image_filter_module.so
        +-- ngx_http_set_misc_module.so
        +-- ngx_http_vhost_traffic_status_module.so
        +-- ngx_stream_geoip2_module.so
    
    2 directories, 14 files
    backup finished...
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.15.7-gcc-7.3.1-20180303-openssl-1.1.1a-071218-221102-hpack-cfzlib
    --------------------------------------------------------
     
  8. eva2000

    eva2000 Administrator Staff Member

    53,190
    12,113
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,649
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Just a reminder for Centmin Mod 123.09beta01 and newer folks, that this tools/nginx-binary-backup.sh script can be useful for backing up and rolling back or switching between different Nginx built binaries if you're testing Nginx with various different compile options i.e different GCC versions, OpenSSL/BoringSSL versions etc.
    Code (Text):
    cd /usr/local/src/centminmod
    tools/nginx-binary-backup.sh
    
    tools/nginx-binary-backup.sh {backup|list|restore}
    

    backup existing Nginx binary
    Code (Text):
    tools/nginx-binary-backup.sh backup
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    backup started...
    --------------------------------------------------------
    /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto
    +-- bin
    |   +-- nginx
    +-- dynamic-modules.conf
    +-- dynamic-modules-includes.conf
    +-- modules
        +-- ndk_http_module.so
        +-- ngx_http_echo_module.so
        +-- ngx_http_fancyindex_module.so
        +-- ngx_http_headers_more_filter_module.so
        +-- ngx_http_image_filter_module.so
        +-- ngx_http_set_misc_module.so
    
    2 directories, 9 files
    backup finished...
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto
    --------------------------------------------------------
    

    List backups available
    Code (Text):
    tools/nginx-binary-backup.sh list
    --------------------------------------------------------
    Listing of available Nginx binary/module backups
    --------------------------------------------------------
    /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto
    --------------------------------------------------------
    

    and restoring a specific Nginx binary backup
    Code (Text):
    tools/nginx-binary-backup.sh restore /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto
    --------------------------------------------------------
    Restore Nginx binary/module from backups
    --------------------------------------------------------
    --------------------------------------------------------
    backup current Nginx binary and dynamic modules
    --------------------------------------------------------
    backup started...
    backup finished...
    --------------------------------------------------------
    backup created at /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144652-hpack-cfzlib-lto
    --------------------------------------------------------
    
    restoring...
    
    cp -af /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto/bin/nginx /usr/local/sbin/nginx
    -rwxr-xr-x 1 root root 4.7M Nov  5 14:44 /usr/local/sbin/nginx
    
    cp -af /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto/modules /usr/local/nginx
    total 1.8M
    drwxr-xr-x  2 root root  220 Nov  5 14:45 .
    drwxr-xr-x 11 root root  156 Nov  5 14:46 ..
    -rwxr-xr-x  1 root root 110K Nov  5 14:44 ndk_http_module.so
    -rwxr-xr-x  1 root root 539K Nov  5 14:44 ngx_http_echo_module.so
    -rwxr-xr-x  1 root root 128K Nov  5 14:44 ngx_http_fancyindex_module.so
    -rwxr-xr-x  1 root root 241K Nov  5 14:44 ngx_http_headers_more_filter_module.so
    -rwxr-xr-x  1 root root 130K Nov  5 14:44 ngx_http_image_filter_module.so
    -rwxr-xr-x  1 root root 593K Nov  5 14:44 ngx_http_set_misc_module.so
    
    cp -af /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto/dynamic-modules.conf /usr/local/nginx/conf/dynamic-modules.conf
    -rw-r--r-- 1 root root 518 Nov  5 14:41 /usr/local/nginx/conf/dynamic-modules.conf
    
    cp -af /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto/dynamic-modules-includes.conf /usr/local/nginx/conf/dynamic-modules-includes.conf
    -rw-r--r-- 1 root root 0 Jun 13  2020 /usr/local/nginx/conf/dynamic-modules-includes.conf
    --------------------------------------------------------
    Restored Nginx binary/module from
    /home/backup-nginxbin/1.21.4-gcc-10.2.1-20210130-openssl-1.1.1l-051121-144530-hpack-cfzlib-lto
    --------------------------------------------------------
    nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
    ngxreload
    Reloading nginx configuration (via systemctl):             [  OK  ]
    --------------------------------------------------------
    
     
Thread Status:
Not open for further replies.