• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

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,
0
new_perl_user
Asked:
new_perl_user
  • 2
  • 2
  • 2
2 Solutions
 
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
 
TobiasCommented:
Ok, try to put the full path of temp and not ~Temp.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
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
 
ahoffmannCommented:
scp  Scripts.tar adm@public01:Temp/Scripts_`date +%Y-%m-%d`.tar
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now