Join the community today
Become a Member

Extract backup giving old path in the backup path

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

  1. pamamolf

    pamamolf Well-Known Member

    2,448
    220
    63
    May 31, 2014
    Ratings:
    +377
    Local Time:
    5:00 PM
    Nginx-1.11.x
    MariaDB 10
    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

    27,694
    6,324
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,320
    Local Time:
    12:00 AM
    Nginx 1.13.x
    MariaDB 5.5
    what are exact commands you using to backup and extract - including which directories are you running the commands from ?
     
  3. pamamolf

    pamamolf Well-Known Member

    2,448
    220
    63
    May 31, 2014
    Ratings:
    +377
    Local Time:
    5:00 PM
    Nginx-1.11.x
    MariaDB 10
    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

    27,694
    6,324
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,320
    Local Time:
    12:00 AM
    Nginx 1.13.x
    MariaDB 5.5
    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 Well-Known Member

    2,448
    220
    63
    May 31, 2014
    Ratings:
    +377
    Local Time:
    5:00 PM
    Nginx-1.11.x
    MariaDB 10
    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

    27,694
    6,324
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,320
    Local Time:
    12:00 AM
    Nginx 1.13.x
    MariaDB 5.5
    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 Well-Known Member

    2,448
    220
    63
    May 31, 2014
    Ratings:
    +377
    Local Time:
    5:00 PM
    Nginx-1.11.x
    MariaDB 10
    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 Well-Known Member

    2,448
    220
    63
    May 31, 2014
    Ratings:
    +377
    Local Time:
    5:00 PM
    Nginx-1.11.x
    MariaDB 10
    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

    27,694
    6,324
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,320
    Local Time:
    12:00 AM
    Nginx 1.13.x
    MariaDB 5.5
    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
    
     
    • Like Like x 1