git @ Cat's Eye Technologies Funicular / 3d14a73
Backup and restore commands. Chris Pressey 10 years ago
1 changed file(s) with 37 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
172172 os.exit(1)
173173 end
174174 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.")
176176 return
177177 end
178178 print("init... size: " .. size)
227227 end,
228228
229229 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)
232246 end,
233247
234248 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")
237269 end,
238270 }
239271