Last active
August 29, 2015 14:07
-
-
Save runjak/290eb8a210dc735417c5 to your computer and use it in GitHub Desktop.
Two scripts to perform a backup of several block devices over network.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The two backup scripts ``read.sh`` and ``write.sh`` will be executed as a pair, | |
to copy multiple devices or logical volumes from a host to a local computer. | |
To achive this, a number of steps must be taken: | |
1: Fill targets="" with the same sequence of targets for both scripts, the order being essential. | |
2: Make sure the targets to write to at the client/write.sh part are at least as large as the targets on the host/read.sh part. | |
3: We assume that the host runs an ssh server, but the client may not offer an ssh connection. | |
To get data flowing over network from host to client we'll therefore build a reverse tunnel with ssh. | |
```ssh -R 62222:localhost:62222 $host -N``` | |
Note that we use port ``62222`` on both sides, which is the same port as used with ``nc`` in both scripts. | |
4: Start ``write.sh`` before ``read.sh``, so that it already listens for incoming data before ``read.sh`` tries and failes to connect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Be aware that dd has a leading /dev/! | |
sources="" | |
for s in $sources | |
do | |
echo "Handling source: $s" | |
dd bs=32k if=/dev/$s | gzip | nc -w 5 localhost 62222 | |
sleep 30 | |
echo "Done.." | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Be aware that dd has a leading /dev/! | |
targets="" | |
for t in $targets | |
do | |
echo "Handling data for $t" | |
nc -l -p62222 | gzip -d | dd bs=32k of=/dev/$t | |
echo "Done.." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment