Welcome to Centmin Mod Community
Become a Member

tools/backup-perm.sh backup & restore file/directory permissions

Discussion in 'Centmin Mod Insights' started by eva2000, Feb 26, 2017.

  1. eva2000

    eva2000 Administrator Staff Member

    30,927
    6,911
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,407
    Local Time:
    2:45 AM
    Nginx 1.13.x
    MariaDB 5.5

    Update tools/backup-perm.sh



    From getting started guide step 2

    When you upload via root user in sftp etc, you upload files as root user/group permissions so need to change them to nginx user/group. You can do that manually as per getting started guide step 2 or via cronjob run for tools/backup-perm.sh script. Just updated 123.09beta01's tools/backup-perm.sh script to also ensure nginx user/group permissions are set so you can copy the /usr/local/src/centminmod/tools/backup-perm.sh script to /home/nginx/domains/domain.com/tools/backup-perm.sh

    copy archive flag to preserve permssions where domain.com is your domain name

    Code (Text):
    mkdir -p /home/nginx/domains/domain.com/tools
    cp -a /usr/local/src/centminmod/tools/backup-perm.sh /home/nginx/domains/domain.com/tools/backup-perm.sh
    

    then as per script instructions setup cronjob

    the instructions
    Code (Text):
    ################################################################
    # 1, for centminmod.com LEMP stacks to be placed in
    # /home/nginx/domains/domain.com/tools/backup-perm.sh
    #
    # 2. setup cronjob to run every 6 hours at 11th minute
    # 11 */6 * * * /home/nginx/domains/domain.com/tools/backup-perm.sh backup 2>&1 /dev/null
    #
    

    set cronjob change domain.com to your domain name
    Code (Text):
    11 */6 * * * /home/nginx/domains/domain.com/tools/backup-perm.sh backup 2>&1 /dev/null
    


    example manual run
    Code (Text):
    /home/nginx/domains/newdomain.com/tools/backup-perm.sh backup
    
    -------------------------------------------------------
     backup directory & file permissions for:
     /home/nginx/domains/newdomain.com
    -------------------------------------------------------
    -rw-r--r-- 1 root nginx 3.8K Feb 26 04:11 /home/nginx/domains/newdomain.com/backup/permissions/permissions-260217-041103.acl
    -------------------------------------------------------
    
    ensure directory and files have correct nginx user:group permission
    /usr/bin/chown -R nginx:nginx /home/nginx/domains/newdomain.com
    
    total 0
    drwxr-s--- 7 nginx nginx  73 Feb 26 03:57 .
    drwxr-s--- 4 nginx nginx  49 Feb 26 03:57 ..
    drwxr-s--- 3 nginx nginx  25 Feb 26 03:58 backup
    drwxr-s--- 2 nginx nginx  41 Feb 26 03:57 log
    drwxr-s--- 2 nginx nginx   6 Feb 26 03:57 private
    drwxr-s--- 2 nginx nginx 191 Feb 26 04:00 public
    drwxr-sr-x 2 nginx nginx  28 Feb 26 03:58 tools
    

    Permissions backed up to /home/nginx/domains/newdomain.com/backup/permissions/permissions-260217-041103.acl

    Example excerpt from contents of /home/nginx/domains/newdomain.com/backup/permissions/permissions-260217-041103.acl
    Code (Text):
    cat /home/nginx/domains/newdomain.com/backup/permissions/permissions-260217-041103.acl
    # file: /home/nginx/domains/newdomain.com
    # owner: nginx
    # group: nginx
    # flags: -s-
    user::rwx
    group::r-x
    other::---
    
    # file: /home/nginx/domains/newdomain.com/public
    # owner: nginx
    # group: nginx
    # flags: -s-
    user::rwx
    group::r-x
    other::---
    
    # file: /home/nginx/domains/newdomain.com/public/index.html
    # owner: nginx
    # group: nginx
    user::rw-
    group::r--
    other::---
    
     
    Last edited: Apr 4, 2017
    • Informative Informative x 3