Why not advertise ssh/scp save possibility with sshfs?

Messages about how to use partimage across a network (with the partimaged server, samba, nfs, ...)

Moderator: feffer

LightKnight
Posts: 1
Joined: Thu Sep 04, 2008 10:20 pm

Why not advertise ssh/scp save possibility with sshfs?

Postby LightKnight » Thu Sep 04, 2008 10:24 pm

I just booted on the Ubuntu live CD, installed partimage and sshfs, mounted a remote linux partition with:

$ sudo su -
# mkdir /tmp/server
# sshfs [email protected]:/home/username /tmp/server
# cd /tmp/server
# partimage

And then just saved files as if they were local. No need for complicated nfs setup or getting a client/server thing to work.

sshfs rocks. Also for partimage. Why not advertise it in the docs?

feffer
Posts: 126
Joined: Tue Mar 17, 2009 4:30 am

Postby feffer » Wed Apr 29, 2009 12:10 am

I scripted partimage to run in cron using the client-server model in the partimage docs. This works, but takes a long time on my rather slow NAS server. As LightKnight suggested, using ssh/scp to run partimage from a server works well. Here is my server-side script:

Code: Select all

#!/bin/sh
# Script to image client machine partition locally, then mv to slug
# Makes image of Ubuntu laptop partition (/dev/sda5) from mint_lap or kubby_lap
# Saves locally, then moves it to slug server

# Added so cron will directly run script
set > /tmp/cron.environment

# The target partition must be unmounted or partimage will fail
# "laptop-bak" is set in /home/.ssh/config to authorize ssh with public/private keys
# There are many online tutorials that explain how to do this
ssh laptop-bak umount /dev/sda5 > /dev/null 2>&1;

Today="`date +%m-%d-%Y-%M`"

# This command saves the partition locally to the client machine
# It ends with "> /dev/null 2>&1" to prevent partimage progress feedback
# The "--fully-batch" flag needs the dummy follower "x=y"
ssh laptop-bak partimage save --compress=1 --nodesc --finish=3 --fully-batch x=y /dev/sda5 /home/pep/data/tmp/ubun_images/ubun_lap_$Today.gz > /dev/null 2>&1 &&

# The following copies the finished image from the client machine to the NAS server
# When copied, it deletes the image from the client
# This sequence is faster than using partimaged on the server and saving the image there -- at least on my LAN -- ymmv
cd /home/bak/laptop/ubun_lap/images;
scp -q laptop-bak:/home/pep/data/tmp/ubun_images/*gz* . &&
ssh laptop-bak rm /home/pep/data/tmp/ubun_images/*gz*

# I want a maximum of 3 images of any given partition
# The following deletes the oldest if more than 3
while [ `find -iname '*.gz*' -not -path '*saved*' | wc -l` -ge 4 ];
        do ls -t -1 ./*.gz* | tail --lines 1 | xargs rm;
done

# Finally, the image is made executable -- ready to restore
chmod +x *`date +%m-%d-%Y`*gz*
This script finished almost twice as fast as the partimaged one on my LAN. One advantage of the above script is that I can trigger it from cron on my client laptop and direct it to image an unbooted partition. Hope some find this useful.

feffer


Return to “Usage across network”

Who is online

Users browsing this forum: No registered users and 2 guests