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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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
Ok, try to put the full path of temp and not ~Temp.
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

> .. 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.

scp  Scripts.tar adm@public01:Temp/Scripts_`date +%Y-%m-%d`.tar

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.