Unix script to create a backup on a remote computer


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unix script to create a backup on a remote computer
# 1  
Old 05-27-2012
Unix script to create a backup on a remote computer

Hello, I have a problem - I attended a UNIX course a couple of years back but, unfortunately, I don't remember how to write scripts for shell commands. Now I want to make a script that makes a backup of a folder on a remote computer and I have no idea how to begin. Smilie

So the idea is that I want the script to create a series of archives of a target directory, each archive must be no larger than 2GB in size and files should be each put in only one archive (as opposed to half of the file in archive1 and the other half in archive2), do not worry there are no files bigger than 2GB Smilie . For the transfer along the net I remember something about "ssh" and generated keys - to avoid password requst every time.

I also want the script to create a text file which indicates which file is in which archive or which archive contains which files, whichever.


Thank you!
# 2  
Old 05-27-2012
will it be same with `create a backup script on remote computer > run ssh from local computer to remote computer > run backup script on remote computer`?
# 3  
Old 06-03-2012
Yes, it is the same.
# 4  
Old 06-06-2012
script for backup

you are doing from the local server.
create one file like(ex: dir-login-ip.txt) -->enter remote servers which u need to take backup
192.168.1.11:/opt/
192.168.1.12:/etc/samba /etc/squid
...................

This is the main backup script.
cd /mnt/backup
export backupdir=backup-$(date +%y-%m-%d_%H-%M-%S)
mkdir /mnt/backup/$backupdir -->where backup is stored with backup date
export datadir=/mnt/backup/$backupdir

cd /home/users/backup/ -->here the main script and dir-login-ip.txt file exists
export IFS=":"
while read server directory
do
export FILE="${datadir}/${server}.gz"
ssh -n $server "sudo tar -c ${directory} |gzip -9" > "$FILE"
echo "Done backup from $server to $FILE on `date`"
done < dir-login-ip.txt


if u dont want to enter passwords for the remote machine u should create password less login by using ssh-keygen.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Triggering remote UNIX shell script from Remote desktop

I m trying to run a batch script in remote desktop which executes unix commands on the unix server...the problem is i wnt the output in HTML format.so in my batch script i m giving the cmd like ssh hostname path ksh HC_Report.ksh>out.html ...but it generates the HTML file in remote desktop .i... (2 Replies)
Discussion started by: navsan
2 Replies

2. Homework & Coursework Questions

Create a simple bash backup script of a file

This is the problem: Write a script that will make a backup of a file giving it a ‘.bak’ extension & verify that it works. I have tried a number of different scripts that haven't worked and I haven't seen anything really concise and to the point via google. For brevity's sake this is one of the... (4 Replies)
Discussion started by: demet8
4 Replies

3. Shell Programming and Scripting

How to create a simple shell script to backup

Hello - I am in process of deleting many files which are older than 4 weeks. For example I am inside: /subsystem/prod/ Files are with various extentions, but anything older than 4 weeks should be deleted. What would be the most simplest script to acheive this? (4 Replies)
Discussion started by: DallasT
4 Replies

4. AIX

backup script failed with error '0403-005 Cannot create the specified file'

In AIX 5.1, a daily run script that backing up oracle data failed yesterday with following errors: The Tivoli backup of DBPROD failed. What could be the issue, OS, backup or Oracle? (3 Replies)
Discussion started by: jalite19
3 Replies

5. UNIX for Advanced & Expert Users

currenlty logged in user on remote computer

Hello everyone Does anyone know, if there is a command that tells you who is logged in on remote host? I'm ssh-ing as root to the remote host and then run whoami but that doesn't tells me who is logged in that particular computer instead shows my remote login. Is there a way to do that?... (2 Replies)
Discussion started by: goude
2 Replies

6. UNIX for Advanced & Expert Users

loggin remote computer as a super user.

hello all, can i loggin remote computer as a super user(i know root user/passwd) and change his access controlle list. if yes please tell me how to do it, i am new to linux. thank you. (6 Replies)
Discussion started by: zius_oram
6 Replies

7. Shell Programming and Scripting

Access a remote computer using perl

Dear all, Where can i find documentation on how to access a remote computer using a perl script? I search to the internet but i can not find something straightforward to this issue. Which is the easiest way to do that? What i would like to do is to access a remote computer access a directory... (5 Replies)
Discussion started by: chriss_58
5 Replies

8. Shell Programming and Scripting

copy file from script file to remote computer

hi, i want copy one or group of file from a computer to others, but i have some problem that do not allow me to do this. i do this by scp command like this : scp <file name> root@cpName:destinationAddress but the problem is that it do not it automatically. it means when it is connecting to... (4 Replies)
Discussion started by: MShirzadi
4 Replies

9. Shell Programming and Scripting

copying files from remote computer

hi, i want to copy files from a remote computer in a network to a specific directory on my PC. ( script ) Forexample , IP of the remote PC is 172.16.5.24 login:aaaa Passw:123 /folder1/file1.txt to my pc folder /fd/awa.txt kinldy help Thanks (2 Replies)
Discussion started by: krabu
2 Replies

10. UNIX for Dummies Questions & Answers

transferring files to and from remote computer

Hi all, i first have to ssh into my university account and then through there another ssh into my office computer, from my home computer. I have been trying to transfer files to and from with no such luck. How do i send a file from home to my office computer. Do I have to send it to my... (6 Replies)
Discussion started by: yogi1
6 Replies
Login or Register to Ask a Question