Join the community today
Register Now

Backup also permissions of files and folders

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

  1. pamamolf

    pamamolf Well-Known Member

    2,819
    251
    83
    May 31, 2014
    Ratings:
    +445
    Local Time:
    4:49 PM
    Nginx-1.13.x
    MariaDB 10.1.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

    30,926
    6,911
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,407
    Local Time:
    12:49 AM
    Nginx 1.13.x
    MariaDB 5.5
    google search for the tar -p option to preserve permissions ;)
     
    • Like Like x 1
  3. pamamolf

    pamamolf Well-Known Member

    2,819
    251
    83
    May 31, 2014
    Ratings:
    +445
    Local Time:
    4:49 PM
    Nginx-1.13.x
    MariaDB 10.1.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

    30,926
    6,911
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,407
    Local Time:
    12:49 AM
    Nginx 1.13.x
    MariaDB 5.5
    read tar manual tar ;)
     
  5. pamamolf

    pamamolf Well-Known Member

    2,819
    251
    83
    May 31, 2014
    Ratings:
    +445
    Local Time:
    4:49 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    Doesn't say anything if i must use -p option on extract also :(
     
  6. eva2000

    eva2000 Administrator Staff Member

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