Solved

Shell script to tar files

Posted on 2012-03-15
6
324 Views
Last Modified: 2012-06-27
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,
0
Comment
Question by:new_perl_user
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Expert Comment

by:MadShiva
ID: 37725194
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
 

Author Comment

by:new_perl_user
ID: 37726208
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
 
LVL 10

Assisted Solution

by:MadShiva
MadShiva earned 400 total points
ID: 37726617
Ok, try to put the full path of temp and not ~Temp.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 37728351
> .. 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
 

Author Comment

by:new_perl_user
ID: 37730889
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
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 37731211
scp  Scripts.tar adm@public01:Temp/Scripts_`date +%Y-%m-%d`.tar
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question