Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- function backup1()
- backup = fs.open(".backupsaving123", "w")
- files = fs.list("disk/")
- for i = 1,#files do
- if not fs.isReadOnly(files[i]) then
- if fs.isDir(files[i]) then
- backup.writeLine('fs.makeDir("' ..files[i].. '")')
- else
- -- Read in the file
- local sName = fs.getName( files[i] )
- if sName == ".backupsaving123" then else
- local file = fs.open( files[i], "r" )
- local sText = file.readAll()
- file.close()
- -- POST the contents to pastebin
- write( "Backing up disk/" ..sName.. "..." )
- local key = "0ec2eb25b6166c0c27a394ae118ad829"
- local response = http.post(
- "http://pastebin.com/api/api_post.php",
- "api_option=paste&"..
- "api_dev_key="..key.."&"..
- "api_paste_format=lua&"..
- "api_paste_name="..textutils.urlEncode(sName).."&"..
- "api_paste_code="..textutils.urlEncode(sText)
- )
- if response then
- local sResponse = response.readAll()
- response.close()
- local sCode = string.match( sResponse, "[^/]+$" )
- backup.writeLine( 'shell.run("pastebin", "get", "'..sCode..'", "disk/'..files[i]..'")')
- end
- end
- end
- end
- end
- backup.close()
- -- Read in the file
- local sName = fs.getName( ".backupsaving123" )
- local file = fs.open( ".backupsaving123" , "r" )
- local sText = file.readAll()
- file.close()
- -- POST the contents to pastebin
- write( "Connecting to pastebin.com... " )
- local key = "0ec2eb25b6166c0c27a394ae118ad829"
- local response = http.post(
- "http://pastebin.com/api/api_post.php",
- "api_option=paste&"..
- "api_dev_key="..key.."&"..
- "api_paste_format=lua&"..
- "api_paste_name="..textutils.urlEncode(sName).."&"..
- "api_paste_code="..textutils.urlEncode(sText)
- )
- if response then
- local sResponse = response.readAll()
- response.close()
- local sCode = string.match( sResponse, "[^/]+$" )
- shell.run("label","set","bottom", sCode)
- else
- print("Failed.")
- end
- fs.delete(".backupsaving123")
- end
- function backup2(id)
- shell.run("pastebin", "get", id, "backupretreiver")
- shell.run("backupretreiver")
- fs.delete("backupretreiver")
- shell.run("clear")
- os.reboot()
- end
- os.pullEvent = os.pullEventRaw
- if fs.exists("disk") then
- print("NeXuS Vault v1 Booted.")
- print("1; Register")
- print("2; Send files")
- print("3; Download files")
- write("\n\nSelection: ")
- repeat
- input = read()
- until tonumber(input) < 4
- if input == "3" then
- backup1()
- shell.run("clear")
- os.reboot()
- elseif input == "2" then
- backup2(disk.getLabel("bottom"))
- end
- else
- print("Please insert a disk.")
- sleep(1)
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment