Unix People Please... tar over scp

Discussion in 'Mac Apps and Mac App Store' started by madamimadam, Aug 19, 2003.

  1. madamimadam macrumors 65816

    madamimadam

    Joined:
    Jan 3, 2002
    #1
    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.
     
  2. visor macrumors 6502

    Joined:
    May 13, 2003
    Location:
    in bed
    #2
    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.
     
  3. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #3
    Re: Unix People Please... tar over scp

    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
     
  4. visor macrumors 6502

    Joined:
    May 13, 2003
    Location:
    in bed
    #4
    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.
     
  5. madamimadam thread starter macrumors 65816

    madamimadam

    Joined:
    Jan 3, 2002
    #5
    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"
     
  6. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #6
    how are you getting around the ssh login step?
     
  7. madamimadam thread starter macrumors 65816

    madamimadam

    Joined:
    Jan 3, 2002
    #7
    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.
     
  8. madamimadam thread starter macrumors 65816

    madamimadam

    Joined:
    Jan 3, 2002
    #8
    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
     

Share This Page