Imposta backup robocopy su share Windows
This commit is contained in:
@@ -86,14 +86,14 @@ class BakRestConfigApp(ctk.CTk):
|
||||
|
||||
self.server_host_var = tk.StringVar()
|
||||
self.server_port_var = tk.StringVar()
|
||||
self.remote_destination_var = tk.StringVar()
|
||||
self.rsync_path_var = tk.StringVar()
|
||||
self.engine_var = tk.StringVar()
|
||||
self.robocopy_path_var = tk.StringVar()
|
||||
self.shutdown_on_success_var = tk.BooleanVar()
|
||||
|
||||
_label_entry(backup_frame, "Server", self.server_host_var, 0)
|
||||
_label_entry(backup_frame, "Porta TCP", self.server_port_var, 1)
|
||||
_label_entry(backup_frame, "Destinazione remota", self.remote_destination_var, 2)
|
||||
_label_entry(backup_frame, "Percorso rsync", self.rsync_path_var, 3)
|
||||
_label_entry(backup_frame, "Motore backup", self.engine_var, 2)
|
||||
_label_entry(backup_frame, "Percorso robocopy", self.robocopy_path_var, 3)
|
||||
|
||||
shutdown_check = ctk.CTkCheckBox(
|
||||
backup_frame,
|
||||
@@ -102,8 +102,15 @@ class BakRestConfigApp(ctk.CTk):
|
||||
)
|
||||
shutdown_check.grid(row=4, column=0, columnspan=2, sticky="w", padx=12, pady=8)
|
||||
|
||||
destinations_frame = ctk.CTkFrame(self.general_tab)
|
||||
destinations_frame.grid(row=2, column=0, columnspan=2, sticky="nsew", padx=0, pady=(0, 8))
|
||||
destinations_frame.grid_columnconfigure(0, weight=1)
|
||||
destinations_frame.grid_rowconfigure(0, weight=1)
|
||||
self.remote_destinations = _ListEditor(destinations_frame, "Share destinazione", browse_dirs=True)
|
||||
self.remote_destinations.grid(row=0, column=0, sticky="nsew", padx=12, pady=12)
|
||||
|
||||
actions = ctk.CTkFrame(self.general_tab, fg_color="transparent")
|
||||
actions.grid(row=2, column=0, columnspan=2, sticky="ew", pady=(0, 8))
|
||||
actions.grid(row=3, column=0, columnspan=2, sticky="ew", pady=(0, 8))
|
||||
actions.grid_columnconfigure(0, weight=1)
|
||||
|
||||
save_button = ctk.CTkButton(actions, text="Salva configurazione", command=self._save_config)
|
||||
@@ -153,8 +160,9 @@ class BakRestConfigApp(ctk.CTk):
|
||||
|
||||
self.server_host_var.set(str(backup.get("server_host", "")))
|
||||
self.server_port_var.set(str(server_check.get("port", 22)))
|
||||
self.remote_destination_var.set(str(backup.get("remote_destination", "")))
|
||||
self.rsync_path_var.set(str(backup.get("rsync_path", "rsync")))
|
||||
self.engine_var.set(str(backup.get("engine", "robocopy")))
|
||||
self.robocopy_path_var.set(str(backup.get("robocopy_path", "robocopy")))
|
||||
self.remote_destinations.set_items(_configured_destinations(backup))
|
||||
self.shutdown_on_success_var.set(bool(backup.get("shutdown_on_success", True)))
|
||||
|
||||
def _save_config(self) -> None:
|
||||
@@ -168,8 +176,10 @@ class BakRestConfigApp(ctk.CTk):
|
||||
watch["exclude_patterns"] = self.exclude_patterns.items()
|
||||
|
||||
backup["server_host"] = self.server_host_var.get().strip()
|
||||
backup["remote_destination"] = self.remote_destination_var.get().strip()
|
||||
backup["rsync_path"] = self.rsync_path_var.get().strip() or "rsync"
|
||||
backup["engine"] = self.engine_var.get().strip() or "robocopy"
|
||||
backup["robocopy_path"] = self.robocopy_path_var.get().strip() or "robocopy"
|
||||
backup["remote_destinations"] = self.remote_destinations.items()
|
||||
backup["remote_destination"] = backup["remote_destinations"][0] if backup["remote_destinations"] else ""
|
||||
backup["shutdown_on_success"] = bool(self.shutdown_on_success_var.get())
|
||||
server_check["port"] = _safe_int(self.server_port_var.get(), 22)
|
||||
|
||||
@@ -333,6 +343,14 @@ def _safe_int(value: str, default: int) -> int:
|
||||
return default
|
||||
|
||||
|
||||
def _configured_destinations(backup: dict[str, object]) -> list[str]:
|
||||
destinations = backup.get("remote_destinations")
|
||||
if isinstance(destinations, list):
|
||||
return [str(item) for item in destinations]
|
||||
destination = str(backup.get("remote_destination", ""))
|
||||
return [destination] if destination else []
|
||||
|
||||
|
||||
def main() -> int:
|
||||
app = BakRestConfigApp()
|
||||
app.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user