Computer Hope

Software => BSD, Linux, and Unix => Topic started by: Embed on November 11, 2011, 10:44:26 AM

Title: Tar Command Help
Post by: Embed on November 11, 2011, 10:44:26 AM
Hi there,

Currently trying to write a backup/restore script but I'm having difficulty getting the restore/extract function to work as desired.

My directory structure is;
/root/scriptfiles/backups

with the scripts being held in:
/root/scriptfiles/


I'm currently using this command, which isn't working and need help with!

Code: [Select]
tar -xvf /root/scriptfiles/backups/"$filename" /root/scriptfiles/backups/"$filename" > /root/scriptfiles/logfiles/"Restore-$filename"
I'm unsure as to the syntax to use, just a beginner.

What I'm trying to achieve with this script is to take the backed up files from the backup folder and extract them to the /root/ directory and rename of the extracted backed up directory to have "Restore-" at the start of the name.
i.e. Restore-Pictures-backup from Pictures-backup.tar

I hope this makes sence, been doing my head in for a while haha.

Thanks in advance for any guidance :)

Em
Title: Re: Tar Command Help
Post by: Rob Pomeroy on November 17, 2011, 01:30:36 AM
Do the extract first and the rename second; don't try and do it all in one line.  "man tar" is your command line friend.