Shell script to tar files


Can someone please help me with code snippet for the below logic:

Need to take a backup of folder on  UNIX box then Tar it  and SCP it to another UNIX  box.

Who is Participating?
ahoffmannConnect With a Mentor Commented:
scp  Scripts.tar adm@public01:Temp/Scripts_`date +%Y-%m-%d`.tar

Something like this  :

tar the folder to backup :
tar -vcf myarchive.tar /home/myfolder

then scp :

scp myarchive.rar login@server:/home/destinationfolder

Best Regards
new_perl_userAuthor Commented:

Thanks for the code. I tried something like below and it did not scp the tar file:


tar -vcf  Scripts.tar /usr/home/qa/Scripts

scp  Scripts.tar adm@public01:~Temp
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

TobiasConnect With a Mentor Commented:
Ok, try to put the full path of temp and not ~Temp.
> .. it did not scp ..
could you please explain what "dit not scp" means in reality?

>  adm@public01:~Temp
does user adm on public01 have permissions to write to user's Temp home directory?
did you probably want to use:

  scp  Scripts.tar adm@public01:Temp/
new_perl_userAuthor Commented:
I tried by declaring the full path and it worked, thank you.

One small request  can we append a current date to the Scripts.tar (like Scripts_03-16.2012.tar) . Because this script will run every night at 12 and will make a backup copy everyday.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.