SurfahBoy808 Posted May 4, 2005 Share Posted May 4, 2005 I was impressed by you guys the last time I asked for a script. I was looking for a script that can resize a whole directory of jpg's to a certain size. That was sweet. Now I have another script, or challenge, or whatever you want to call it. :D I'm looking for a script that will tar both my home and etc directories, then bzip them, then push it to my server where I have a backup hard drive that can store it. I would like to put this script as a cron job so it can backup my stuff daily. my current pc is lan ip 192.168.X.6 and my server is on 192.168.X.4 and the directory of my hard drive(on my server) I want to save to is called /WD160 thanks in advance, I wish I could code like you guys. Link to comment Share on other sites More sharing options...
theYinYeti Posted May 4, 2005 Share Posted May 4, 2005 Then learn :lol: Seriously, trying is the best way to learn... Anyway, does something like that suits you: # tar cjf - /home /etc | ssh backupuser@remotehost '/path/to/remoteCommand.sh' where ssh is configured to use keys, not passwords/passphrases for user "backupuser", and remoteCommand.sh is a script that simply dumps standard input to whatever filename is the next available (I guess you won't always overwrite the same filename) I leave to you to configure cron. Yves. Link to comment Share on other sites More sharing options...
SurfahBoy808 Posted May 4, 2005 Author Share Posted May 4, 2005 ah, ok, so remoteCommand.sh is another script that just dumps the input to the directory? is that so I don't have to worry about the password when the ssh command executes? what does the '-' after the tar cjf do? Thanks Link to comment Share on other sites More sharing options...
theYinYeti Posted May 4, 2005 Share Posted May 4, 2005 tar c(compress)j(with bzip2)f(to file:) -(standard output) /etc /home |(tar'd bzip2'd result is passed on as standard input to:) ssh backupuser@remotehost '/path/to/remoteCommand.sh' You'll indeed have a problem with ssh asking for a password, except if you configured ssh to work between localhost and remotehost using only private/public keys. I know that can be done, but I don't know how. The following article may help: http://www.linuxquestions.org/questions/an...rticle&artid=79 Now the /path/to/remoteCommand.sh script. In its simplest form, it lives in /usr/local/sbin, and contains: #!/bin/bash cat >/var/backup.tar.bz2 But simple like that, the same file will get overwritten over and over again. So you may want to improve it a bit to (for example) list the currently existing backup files, and create a new unique name, so that no old backup gets overwritten. Yves. Link to comment Share on other sites More sharing options...
SurfahBoy808 Posted May 5, 2005 Author Share Posted May 5, 2005 Then learn :lol: Seriously, trying is the best way to learn... Anyway, does something like that suits you: # tar cjf - /home /etc | ssh backupuser@remotehost '/path/to/remoteCommand.sh' where ssh is configured to use keys, not passwords/passphrases for user "backupuser", and remoteCommand.sh is a script that simply dumps standard input to whatever filename is the next available (I guess you won't always overwrite the same filename) I leave to you to configure cron. Yves. <{POST_SNAPBACK}> thanks for breaking it down for me. Man only has so much things and it wont have symbols like the '-' I need to figure out a way to avoid the password since I need it to run without me being present Link to comment Share on other sites More sharing options...
papaschtroumpf Posted May 6, 2005 Share Posted May 6, 2005 (edited) Is it really necessary to use ssh at all? sounds like he's on a local LAN otherwise could encrypt the tar file with pgp before transmitting Edited May 6, 2005 by papaschtroumpf Link to comment Share on other sites More sharing options...
SurfahBoy808 Posted May 8, 2005 Author Share Posted May 8, 2005 Is it really necessary to use ssh at all? sounds like he's on a local LAN otherwise could encrypt the tar file with pgp before transmitting <{POST_SNAPBACK}> I am on a local LAN, in my house. So how can I push the tar file without having to type in passwords and what not? Link to comment Share on other sites More sharing options...
Guest ChillyWillie Posted July 22, 2005 Share Posted July 22, 2005 As long as your script is in a secure location with permissions 500, you should be able to insert the password in plaintext on the command line. I believe adding a "-p password' is the correct syntax, but check it in the man file. Of course, setting up the crypto keys is much much safer. If you don't forward port 22 to any of your machines, that would be isolated enough to keep nosey script-kiddies away. Along the same lines, you could block FTP ports 20-21 and run an anonymous FTP server behind your firewall. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now