-
Notifications
You must be signed in to change notification settings - Fork 6
/
packages-import.bsh
49 lines (35 loc) · 2 KB
/
packages-import.bsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#DESCRIPTION
#import a zfs file system with historical MRAN snapshots to a zpool
#run this script or commands on your MRAN server candidate
#SETUP - change these variables as needed
MASTER_URL="mran.revolutionanalytics.com" #change to your server URL if not pointing to Revo master
RSYNC_MODULE="MRAN-exports" #-------------#only change if not using Revo master
ARCHIVE="mran-2014-6-30_517pm.zfs" #------#use the latest replication stream from Revo master
TMP_DESTINATION="/tmp" #------------------#this temp holding area needs to be large enough to hold a full archive
#See http://mran.revolutionanalytics.com/accounting.txt for a current MRAN size
MRAN_HOME="MRAN" #------------------------#name of zpool where you want to import packages snapshot stream to
#STEP 1 - get a replication stream from master MRAN server
#we use rsync for higher efficiency over WAN
#base rsync URL and module for Revo master server exports
#rsync -tv mran.revolutionanalytics.com::MRAN-exports
#choose an appropriate export
#note this example is a comprehensive replication stream current as of the date
#displayed in the file name.
rsync -tv $MASTER_URL::$RSYNC_MODULE/$ARCHIVE $TMP_DESTINATION
#STEP 2 -import the replication stream to your zpool or FS
#WARNING - use zfs recv switches with care
#below are the two most likely switches you will need
#use at your own risk!
#from the zfs man page:
# -F
#Force a rollback of the file system to the most recent snapshot before performing
#the receive operation. If receiving an incremental replication stream
#(for example, one generated by zfs send -R -[iI]), destroy snapshots and
#file systems that do not exist on the sending side.
# -d
#Cause the file system name of the target snapshot to be determined by appending
#a portion of the sent snapshot's name to the specified target filesystem.
#note that if you have an existing pool/fs combo, you can use that name here in
#place of `MRAN`
sudo zfs recv -F -d $MRAN_HOME < /$TMP_DESTINATION/$ARCHIVE