Project

General

Profile

« Previous | Next » 

Revision 13260

lib/sh/sync.sh: db_snapshot(): factored copy operation out into separate db_copy() function

View differences:

sync.sh
49 49
	src="$local_dir" dest="$remote_url" command put "$@"
50 50
}
51 51

  
52
db_snapshot() # usage: [live=] ctl=... from=... [to=...] db_snapshot
53
# ctl(cmd:{start|stop}): daemon controller that takes command param
52
db_copy() # usage: [live=] from=... [to=...] db_copy
53
# **IMPORTANT**: to produce a consistent snapshot, DB must be shut down
54 54
{
55
	echo_func; kw_params live ctl from to; : "${ctl:?}" "${from:?}"
55
	echo_func; kw_params live from to; : "${from:?}"
56 56
	local_export live="${live-1}"; local to="${to:-$from.bak}"
57 57
	sudo mkdir "$to"
58 58
	
59
	local_dir="$from" remote_url="$to" inplace=1 sudo upload
60
		# inplace: for large files, don't re-copy entire file
61
}
62

  
63
db_snapshot() # usage: [live=] ctl=... from=... [to=...] db_snapshot
64
# ctl(cmd:{start|stop}): daemon controller that takes command param
65
{
66
	echo_func; kw_params ctl from to; : "${ctl:?}"
67
	
59 68
	sudo "$ctl" stop
60
	prep_try; local_dir="$from" remote_url="$to" inplace=1 "try" sudo upload
61
		# inplace: for large files, don't re-copy entire file
69
	try db_copy
62 70
	sudo "$ctl" start
63 71
	rethrow
64 72
}

Also available in: Unified diff