Solved

Shell script to tar files

Posted on 2012-03-15
6
322 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now