restore_backups.lua

74 lines ยท 1.7 KB

Open raw

eHydra Backup Restoration System

Copy & run

wget https://perlytiara.github.io/turtles.tips/raw/programs/perlytiara/eHydra_wip/restore_backups.lua
1-- eHydra Backup Restoration System
2-- Restores eHydra programs from backup files
3
4local eHydraPrograms = {
5 "autoupdater.lua",
6 "batch_updater.lua",
7 "init.lua",
8 "turtle_deployer.lua",
9 "startup.lua",
10 "self_update.lua",
11 "README.md"
12}
13
14print("eHydra Backup Restoration v1.0")
15print("==============================")
16
17-- Check for available backups
18local backupsFound = {}
19for _, filename in ipairs(eHydraPrograms) do
20 local backupPath = filename .. ".backup"
21 if fs.exists(backupPath) then
22 table.insert(backupsFound, filename)
23 end
24end
25
26if #backupsFound == 0 then
27 print("โŒ No backup files found.")
28 print("Backups are only created during updates.")
29 return
30end
31
32print("๐Ÿ“ฆ Found " .. #backupsFound .. " backup file(s):")
33for i, filename in ipairs(backupsFound) do
34 print(" " .. i .. ". " .. filename)
35end
36
37print()
38write("Restore all backups? (y/n) [n]: ")
39local confirm = string.lower(read())
40
41if confirm ~= "y" then
42 print("Restoration cancelled.")
43 return
44end
45
46print()
47print("๐Ÿ”„ Restoring backup files...")
48
49local restored = 0
50for _, filename in ipairs(backupsFound) do
51 local backupPath = filename .. ".backup"
52
53 print("Restoring " .. filename .. "...")
54
55 -- Delete current file if it exists
56 if fs.exists(filename) then
57 fs.delete(filename)
58 end
59
60 -- Restore from backup
61 fs.copy(backupPath, filename)
62 fs.delete(backupPath)
63
64 print(" โœ… " .. filename .. " restored")
65 restored = restored + 1
66end
67
68print()
69print("๐ŸŽ‰ Restoration complete!")
70print("โœ… Restored " .. restored .. " files")
71print("๐Ÿ—‘๏ธ Backup files have been removed")
72print()
73print("eHydra has been restored to previous versions.")
74