LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   backup/restore HomeFolder/DataFolder with Tar without full path (https://www.linuxquestions.org/questions/linux-newbie-8/backup-restore-homefolder-datafolder-with-tar-without-full-path-4175593449/)

giobaxx 11-13-2016 08:29 AM

backup/restore HomeFolder/DataFolder with Tar without full path
 
Hello guys, first sorry for my basic english. I had to started to work with linux, even if for the moment a i make basics things i would like to do it in the better way as possible

Sometimes i have to move data between Ubuntu Workstation, mainly data from home profile but not only

if i want to backup the home folder of a standard user joe using my administrative accounts admin
i run the following command:

I want to save only the data preserving the permission(not temp files, configuration files, cache files, hidden files )

Can you tell me if the command below is a good choice?

Code:

tar -cpvzf /mnt/mybackup_Folder/back_joe.tar.gz /home/joe --exclude='.*'

When i restore the tar it recreate all the full path. So for example if i restore the tar inside /home/joe/Document/Restored_Files i will found

/
Code:

home/joe/Documents/Restored_Files/home/joe/Documents
/home/joe/Documents/Restored_Files/home/joe/Desktop
/home/joe/Documents/Restored_Files/home/joe/Download

etc

I would like to restore without full path as below:

Code:

/home/joe/Documents/Restored_Files/Documents
/home/joe/Documents/Restored_Files/Desktop
/home/joe/Documents/Restored_Files/Download

I tried with the option -C but maybe i didnt undestand as it works...

can you help me?

rigor 11-13-2016 01:00 PM

giobaxx,

If you just want to avoid having the home directory in the path, you can manually cd into the home directory, before running tar; then instead of using for example /home/joe in the tar command, use the "period" character, like this:

Code:

cd /home/joe
tar -cpvzf /mnt/mybackup_Folder/back_joe.tar.gz  .  --exclude='.*



All times are GMT -5. The time now is 05:22 PM.