Project

General

Profile

« Previous | Next » 

Revision 13264

lib/sh/sync.sh: db_copy() and callers: pass args as rsync options

View differences:

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

  
52
db_copy() # usage: [live=] from=... [to=...] db_copy
52
db_copy() # usage: [live=] from=... [to=...] db_copy rsync_opts...
53 53
# **IMPORTANT**: to produce a consistent snapshot, DB must be shut down
54 54
{
55 55
	echo_func; kw_params live from to; : "${from:?}"
......
57 57
	sudo mkdir "$to"
58 58
	
59 59
	local_dir="$from" remote_url="$to" inplace=1 sudo upload --delete-excluded \
60
--exclude=.DO_NOT_BACKUP # allow tape backup
60
--exclude=.DO_NOT_BACKUP "$@" # allow tape backup
61 61
		# inplace: for large files, don't re-copy entire file
62 62
}
63 63

  
64
db_snapshot() # usage: [live=] ctl=... from=... [to=...] db_snapshot
64
db_snapshot() # usage: [live=] ctl=... from=... [to=...] db_snapshot rsync_opts
65 65
# ctl(cmd:{start|stop}): daemon controller that takes command param
66 66
{
67 67
	echo_func; kw_params ctl from to; : "${ctl:?}"
68 68
	
69 69
	# copy changes before stopping DB to minimize the time that it's shut down
70
	db_copy # copy changes since last backup
71
	db_copy # copy changes that occurred during the copy operation
70
	db_copy "$@" # copy changes since last backup
71
	db_copy "$@" # copy changes that occurred during the copy operation
72 72
	
73 73
	# make copy a consistent snapshot
74 74
	sudo "$ctl" stop
75
	try db_copy
75
	try db_copy "$@"
76 76
	sudo "$ctl" start
77 77
	rethrow
78 78
}
trunk/lib/sh/db.sh
249 249
sudo service mysql "$@" # ignore errors if not running
250 250
}
251 251

  
252
mysql_snapshot() # usage: [live=] [from=...] [to=...] mysql_snapshot
252
mysql_snapshot() # usage: [live=] [from=...] [to=...] mysql_snapshot rsync_opts
253 253
{
254 254
	echo_func; kw_params from to; local from="${from:-/var/lib/mysql}"
255
	ctl=mysql_ctl db_snapshot
255
	ctl=mysql_ctl db_snapshot "$@"
256 256
}
257 257

  
258 258

  
......
419 419
	sudo service postgresql "$@"
420 420
}
421 421

  
422
pg_snapshot() # usage: [live=] [from=...] [to=...] pg_snapshot
422
pg_snapshot() # usage: [live=] [from=...] [to=...] pg_snapshot rsync_opts...
423 423
{
424 424
	echo_func; kw_params from to; local from="${from:-/var/lib/postgresql}"
425
	ctl=pg_ctl db_snapshot
425
	ctl=pg_ctl db_snapshot "$@"
426 426
}
427 427

  
428 428
fi

Also available in: Unified diff