Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Tar Command Help  (Read 3679 times)

0 Members and 1 Guest are viewing this topic.

Embed

  • Guest
Tar Command Help
« 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

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Tar Command Help
« Reply #1 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.
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos