Shell script to tar files

Hi,

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.

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

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
0
 
new_perl_userAuthor Commented:
Hi,

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


#!/bin/bash

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

scp  Scripts.tar adm@public01:~Temp
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
TobiasConnect With a Mentor Commented:
Ok, try to put the full path of temp and not ~Temp.
0
 
ahoffmannCommented:
> .. 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/
0
 
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.

Thanks,
0
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.