Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

madamimadam

macrumors 65816
Original poster
Jan 3, 2002
1,281
0
Hey, we've been working on a script here for our daily back up which includes:

tar -czf Destination /Users
scp Source Destination
rm Source

The obvious problem with this is that it is tar.gzing to the source machine and then sending to the server and certain machines are running out of memory (inc. mine since I have a lot of AACs).

What I would like is:

tar -czf user@IP:/Volumes/BackUp/backup.tar.gz /Users

I have been told that I can get something like that to work using standard output with a pipe and ssh command but I can't for the life of me get it to work.
 

visor

macrumors 6502
May 13, 2003
341
0
in bed
I'm to lazy to try, but have you tried

tar -cz bla |scp user@bla

the -f flag references to a file resource, i think skipping the f would put it to standard out, or the pipe respectively.
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
Re: Unix People Please... tar over scp

Originally posted by madamimadam
certain machines are running out of memory [...]

tar -czf user@IP:/Volumes/BackUp/backup.tar.gz /Users


by "memory" i assume you mean disk space?

is "BackUp" the name of a drive on your server? if so, and you've got it mounted to your client machine, you can do:


% tar czf /Volumes/BackUp/backup.tar.gz /Users
 

visor

macrumors 6502
May 13, 2003
341
0
in bed
can't get the hang of tar now, but here is something that will work if you cannot mount your server (which would of course be best)

gzip -c files* |ssh 192.168.1.12 "cat >/Users/bla.gz"

where -c menas write to stdout.

If you can persuade tar to write to stdout, it should work likewise.
 

madamimadam

macrumors 65816
Original poster
Jan 3, 2002
1,281
0
Thanks for the info

Here is what I am doing now until I work out the best solution that copies resource forks

#!/bin/sh
NAME=`hostname`
tar --bzip2 -cf - /Users | ssh backup@192.168.0.4 "cat > /Volumes/BackUp/$NAME.tar.bz2"
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
Originally posted by madamimadam

tar --bzip2 -cf - /Users | ssh backup@192.168.0.4 "cat > /Volumes/BackUp/$NAME.tar.bz2"

how are you getting around the ssh login step?
 

madamimadam

macrumors 65816
Original poster
Jan 3, 2002
1,281
0
Originally posted by zimv20
how are you getting around the ssh login step?

Well, i have not implimented it yet (running manually) but what I'm doing today is creating a text file called authorized_keys in the .ssh folder of the backup server.

I originally just made the user backup one that could log in but had no home folder but by giving it a home folder I am able to add that file and not worry about the log ins.

Sorry, forgot to specify, in the authorized_keys file you add the keys of all the machines that will be logging in. The way I like to find the keys is to simply ssh into all the machines that will be backed up from the back up server. When you ssh into a machine you have to authorise the machine you are logging into and it saves the key in the known_hosts file which is also in the .ssh folder. I'm just going to do a simple copy and paste job from that file.
 

madamimadam

macrumors 65816
Original poster
Jan 3, 2002
1,281
0
To find client key and add to file:

sudo ssh-keygen -t dsa -f /private/var/root/.ssh/id_dsa -C "Comment"

To add this key to authorized_keys:

cat /private/var/root/.ssh/id_dsa.pub | ssh root@192.168.0.4 "cat - >> /Users/backup/.ssh/authorized_keys"

To turn on public key authorisation on the server:

echo "PubkeyAuthentication yes" >> /etc/sshd_config

obviously needs to be run as root on the server
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.