Backup and restore commands.
Chris Pressey
10 years ago
172 | 172 | os.exit(1) |
173 | 173 | end |
174 | 174 | if exists(funicular.system_image) then |
175 | print(funicular.system_image .. " already exists! rm it first.") | |
175 | print(funicular.system_image .. " already exists! Delete it first.") | |
176 | 176 | return |
177 | 177 | end |
178 | 178 | print("init... size: " .. size) |
227 | 227 | end, |
228 | 228 | |
229 | 229 | backup = function(funicular, arg) |
230 | -- copy system image to args[1] | |
231 | -- gzip it | |
230 | bup = arg[2] | |
231 | if bup == nil then | |
232 | print "Usage: funicular backup <backup-basename>" | |
233 | os.exit(1) | |
234 | end | |
235 | ||
236 | bup_img_gz = bup .. '.img.gz' | |
237 | if exists(bup_img_gz) then | |
238 | print(bup_img_gz .. ' already exists! Delete it or pick a different name.') | |
239 | os.exit(1) | |
240 | end | |
241 | ||
242 | execute(funicular, "ls -lah ${SYSTEM_IMAGE}") | |
243 | execute(funicular, "cp ${SYSTEM_IMAGE} " .. bup .. ".img") | |
244 | execute(funicular, "gzip " .. bup .. ".img") | |
245 | execute(funicular, "ls -lah " .. bup_img_gz) | |
232 | 246 | end, |
233 | 247 | |
234 | 248 | restore = function(funicular, arg) |
235 | -- copy args[1] to system image | |
236 | -- gunzip it | |
249 | bup = arg[2] | |
250 | if bup == nil then | |
251 | print "Usage: funicular restore <backup-basename>" | |
252 | os.exit(1) | |
253 | end | |
254 | ||
255 | bup_img_gz = bup .. '.img.gz' | |
256 | if not exists(bup_img_gz) then | |
257 | print(bup_img_gz .. ' does not exist.') | |
258 | os.exit(1) | |
259 | end | |
260 | ||
261 | if exists(funicular.system_image) then | |
262 | print(funicular.system_image .. ' still exists, please delete it first.') | |
263 | os.exit(1) | |
264 | end | |
265 | ||
266 | execute(funicular, "ls -lah " .. bup_img_gz) | |
267 | execute(funicular, "cp " .. bup_img_gz .. " ${SYSTEM_IMAGE}.gz") | |
268 | execute(funicular, "gunzip ${SYSTEM_IMAGE}.gz") | |
237 | 269 | end, |
238 | 270 | } |
239 | 271 |