Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SmilerRyan's Backup And Recovery Tool:
- -- Moves files to disk so they can be recovered later.
- -- NOTE: Recovery will OVERWRITE all files on the machine.
- -- USAGE: Insert floppy with disk in device(s) to copy from/to.
- -- DOWNLOAD (ON EMPTY FLOPPY): pastebin get cbTdp8B0 /disk/startup
- shell.run("clear")
- local DT = "unknown"
- term.setCursorPos(2,2)
- if fs.isDir("/disk/r") then DT = "recovery" else DT = "backup" end
- if term.isColor() then term.setTextColor(colors.yellow) end
- print("Backup/Recovery Tool by SmilerRyan\n")
- print(" This disk will " .. DT .. " your files.")
- print(" Warning: Every file/directory will be moved.\n")
- print(" To cancel the process, press T.")
- print(" Press any key to start...")
- local ignore={["disk"]=true,["rom"]=true}
- local event, key = os.pullEvent( "key" )
- local l = "[Backup Disk] "
- print("")
- if key == keys.t then
- term.clear()
- term.setCursorPos(2,2)
- if term.isColor() then term.setTextColor(colors.red) end
- write("Backup/Recovery Tool by SmilerRyan\n The " .. DT .. " task was cancelled.\n The drive was not ejected.\n\n")
- if term.isColor() then term.setTextColor(colors.white) end
- return
- end
- print(" " .. DT .. " started")
- if fs.isDir("/disk/r") then
- for _, filename in ipairs(fs.list("/disk/r")) do if not ignore[filename] then fs.move("/disk/r/"..filename, "/"..filename) end end
- fs.delete("/disk/r")
- l = l .. "empty"
- else
- fs.makeDir("/disk/r");
- for _, filename in ipairs(fs.list("")) do if not ignore[filename] then fs.move(filename, "/disk/r/"..filename) end end
- l = l .."full"
- end
- local sides = {"top","bottom","left","right","front","back"}
- for i, side in pairs(sides) do
- disk.setLabel(side, l)
- disk.eject(side)
- end
- sleep(2)
- write(" " .. DT .. " complete!\nRebooting...")
- os.reboot()
Add Comment
Please, Sign In to add comment