Welcome to Centmin Mod Community
Become a Member

Backup also permissions of files and folders

Discussion in 'System Administration' started by pamamolf, Oct 5, 2014.

  1. pamamolf

    pamamolf Premium Member Premium Member

    4,068
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    11:55 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Hi

    I am using this command to backup my public folder:

    cd /home/nginx/domains/mydomain.com/
    tar -zcf /home/backup/sitefiles_$(date +\%d-\%m-\%Y).tgz public


    and to restore :
    cd /home/nginx/domains/mydomain.com/
    tar xzvf sitefiles_$(date +\%d-\%m-\%Y).tgz
    chown -R nginx:nginx public

    But how can i add to my backup the option to keep files and folders permissions like 755 for folders or 644 for files and so on?

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    53,142
    12,110
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,645
    Local Time:
    6:55 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    google search for the tar -p option to preserve permissions ;)
     
  3. pamamolf

    pamamolf Premium Member Premium Member

    4,068
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    11:55 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Thanks George :)

    Ok i use it like this:

    tar -zcfp /home/backup/sitefiles_$(date +\%d-\%m-\%Y).tgz public

    But do i have to use the -p parameter also in the extract operation like this?

    tar xzvfp sitefiles_$(date +\%d-\%m-\%Y).tgz
     
    Last edited: Oct 5, 2014
  4. eva2000

    eva2000 Administrator Staff Member

    53,142
    12,110
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,645
    Local Time:
    6:55 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    read tar manual tar ;)
     
  5. pamamolf

    pamamolf Premium Member Premium Member

    4,068
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    11:55 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Doesn't say anything if i must use -p option on extract also :(
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,142
    12,110
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,645
    Local Time:
    6:55 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+