Learn about Centmin Mod LEMP Stack today
Register Now

Extract backup giving old path in the backup path

Discussion in 'System Administration' started by pamamolf, Jun 11, 2014.

  1. pamamolf

    pamamolf Premium Member Premium Member

    4,077
    427
    83
    May 31, 2014
    Ratings:
    +833
    Local Time:
    6:25 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    Hi

    I create a directory /home/backup and when i am on this folder from ssh i backup all files and folders from /home/nginx/mydomain.com/public_html/


    Then when i use this backup and giv ethe path to extract as /home/nginx/mydomain.com/public_html/ i am getting inside the same path and the files and folders like:

    /home/nginx/mydomain.com/public_html//home/nginx/mydomain.com/public_html/files andfolders here :(

    What command should i use to do it correct?
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,341
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    2:25 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    what are exact commands you using to backup and extract - including which directories are you running the commands from ?
     
  3. pamamolf

    pamamolf Premium Member Premium Member

    4,077
    427
    83
    May 31, 2014
    Ratings:
    +833
    Local Time:
    6:25 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    I had this problem long time ago as i have many months to move to another server but as i remember i was run from ssh from directory:

    Code:
    /home/backup
    the command:

    Code:
    tar -zcf backup_files_$(date +\%d-\%m-\%Y).tgz /home/nginx/domains/mydomain.com/public/
    And for restore i am running from ssh the command:

    Code:
    tar xzvf /home/backup_files_datemonthblabla.tgz
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,341
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    2:25 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You probably want to run the backup command one directory level above public

    so do this first before you run the backup command

    Code:
    cd /home/nginx/domains/mydomain.com/
     
  5. pamamolf

    pamamolf Premium Member Premium Member

    4,077
    427
    83
    May 31, 2014
    Ratings:
    +833
    Local Time:
    6:25 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    But the backup is not there it is on /home/backup ?

    Confused....

    So you mean like this?

    Code:
    cd /home/backup
    tar -zcf backup_files_$(date +\%d-\%m-\%Y).tgz /home/nginx/domains/mydomain.com/
    
    restore
    Code:
    cd /home/nginx/domains/mydomain.com/
    tar xzvf /home/backup/backup_files_datemonthblabla.tgz
    
    In general i need only the public folder to backup that i have my files there ....
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,341
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    2:25 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    would be something like

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

    pamamolf Premium Member Premium Member

    4,077
    427
    83
    May 31, 2014
    Ratings:
    +833
    Local Time:
    6:25 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    ok and the backup will be saved at /home/nginx/domains/mydomain.com/ ?

    and how can i restore it correct then?

    Thank you
     
  8. pamamolf

    pamamolf Premium Member Premium Member

    4,077
    427
    83
    May 31, 2014
    Ratings:
    +833
    Local Time:
    6:25 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    Like this ?

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

    Code:
    cd /home/nginx/domains/mydomain.com/
    tar xzvf backup_files_datemonthblabla.tgz
    
    or
    Code:
    tar xzvf backup_files_datemonthblabla.tgz public 
     
  9. eva2000

    eva2000 Administrator Staff Member

    54,341
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    2:25 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    your backup is at /home/backup so

    Code:
    cd /home/backup
    tar xzvf backup_files_datemonthblabla.tgz
    chown -R nginx:nginx public
    \cp -Rpf public /home/nginx/domains/mydomain.com/public