Re: remote server backup script

From: Gautam Bakshi (gautam.bakshi_at_gmail.com)
Date: 02/26/05


Date: Fri, 25 Feb 2005 20:58:09 -0500
To: "Peter T. Breuer" <ptb@lab.it.uc3m.es>

Peter T. Breuer wrote:
> Gautam Bakshi <gautam.bakshi@gmail.com> wrote:
>
>>> find `cat /mylist/of/files` -cnewer /last/backup/reference -fprint0 thislist
>>> touch /last/backup/reference
>>> tar czvfT --null - thislist | ssh server dd of=backup_`date +%Y%m%d`.tgz
>>>
>>
>>So i didn't put any effort, tell me where to start then, please? any
>
>
>
> Just type away at the command line. Make a backup of whatever you want
> to make a backup of.
>
> When you have DONE it, then put your commands, the ones you used on the
> command line, in a script.
>
> Then examine your script, and replace any particular names such as the
> files and directories you chose to back up by variables defined at the
> top of the script.
>
> Then you want to think how to generate the values of those variable
> automatically.
>
> So you START by DOING.
>
>
>
>>books? websites? I know how to back up, using tar(and now thanks to
>
>
> Then you know about all I do.
>
>
>>you, i know how to back up incremental.
>
>
> Oh, I don't. Tar has a mode it calls "incremental".
>
>
> -g, --listed-incremental F
> create/list/extract new GNU-format
> incremental backup
>
> but I really don't think you want it (shudder). Mind you, if you would
> investigate it and see what itt does and then tell me in what way it
> fails to meet the common mans idea of "incremental" I would be
> grateful! Then we could send the complaint to the FSF.
>
>
>
>>and also now thanks to you,
>>again, I know how to name the backup file automatically.
>
>
> what was wrong with
>
> `date`.tgz
>
> ?? That's a good START.
>
> All I did was do the extra work of looking up the parameters to
> give to date to make it generate a date in the format YOU specified.
>
> But there was nothing wrong with just using "date" on its own for a
> starter, and you most certainly do know that.
>
>
>
>>I already
>>knew how to ssh into a machine without a username and password(saving
>>the server ssh key on the clients machine). So what else do i need?
>>The one thing i can't figure out, is how to send the email actually, I
>
>
> Send an email now, to someone. When you have "figured" out how you did
> it, add a line like that command you used to the sscript.
>
>
>>normally know how to send emails when commands are successful from
>
>
> Good. Then send one when successful. Be happy.
>
> Then modify the script to send one when unsuccessful.
>
>
>
>>command line, but i am not sure how to do it if it sftped corrected.
>
>
> "corrected"?
>
>
>
>>I
>>mean, if i do it based on $? (exit status) then i may get succesful
>
>
> Why not?
>
>
>>everytime since the script exits the ssh server correctly. I don't know
>
>
> Maybe, maybe not! Try it and see! What's the matter? Will you be forced
> to shoot your parents if the the script doesn't do it first time?
> Having something which does not work is the first step on the road to
> having something that does work.
>
>
>>how to script it once i'm sftped in. How to exit the ssh server via a
>
>
> Who's asking you to sftp anywhere? I'm puzzled. If you can't do
> something, don't do it! Do something else instead!
>
> But if you are dead set on doing something via sftp (why, oh, why?),
> then you'd better read up on it. I certainly don't want to be involved
> with it. What's wrong with scp or scat or plain ssh?
>
>
>>script.
>>
>>maybe i'll have to show some "effort" and practice it right?
>
>
> You'll have to TRY it! When you have difficulties, then is the time to
> come back, explain the difficulties and the particular point you are
> stuck on, and ask for help in getting yourself past that point.
>
> So far, so good, no?
>
> Peter

yea yea yea

i think i got it to work. I am not a programmer so let me know if there
is any problems with this script. It seems to be doing the job. It
seems to test fine.

I run this script, after adding the clientservers ssh key to the
backupservers trusted keys. (to do that, enter ssh-keygen -t dsa hit
enter until its done,then copy .ssh/id_dsa.pub into the backupserver's
drive then cat id_dsa.pub >> ./ssh/authorized_keys )

#!/bin/sh
filename="backup.$(date +%Y%m%d-%H%M%S).tgz"
filestobackup=`find $1 -cnewer /home/backupuser/backup.sh`
# echo $filestobackup
tar czvf $filename $filestobackup
#tar czvf \home\backupuser\$1.$(date +%Y%m%d-%H%M%S).tgz $1
touch backup.sh
#echo "file name is $filename"
scp -q $filename root@192.168.5.10:
exit $?



Relevant Pages

  • Scripts using SSH and SSH_ASKPASS
    ... To test SSH scripts you better destroy the control TTY. ... The trick is to run YOUR script on YOUR local ... As for the password relaying command: this needs not be an X command. ... # we read one line from a temporary pipe. ...
    (comp.security.ssh)
  • Re: file backup in windows
    ... I want my script to identigy the user ... logged in and go to the resp outlook folder or should be able to read ... operating system to try a few sample commands at the command line. ...
    (comp.lang.python)
  • Re: Need some small help on shell script - delete old files
    ... the grep are then sent to xargs to issue the rm command. ... gzip of $FILENAME at the end is not necessary as far as I can tell ...  Could this possibly be from this script? ... Also not sure why the qzip did not run on last night's backup. ...
    (comp.unix.shell)
  • Re: [PHP] SSH and php
    ... % % Is it possible to run a SSH command from php? ... it's possible to run any command from php. ... There are ways to do that -- I personally would create a kick script ...
    (php.general)
  • Re: backup script directory errors fixed, now it cant find the eof
    ... I run the script and it finds a premature end of file on line 53? ... The:command not founde 21,30,31 are just blank lines. ... # full and incremental backup script ... # The rest of the time an incremental backup is made. ...
    (comp.unix.shell)