initial commit

This commit is contained in:
2025-08-13 22:51:13 -03:00
commit 68377fc083
13 changed files with 35400 additions and 0 deletions

42
restore_script.py Normal file
View File

@@ -0,0 +1,42 @@
import tarfile
import shutil
import os
import glob
def extract_tar_gz(source_file, destination_dir, extract_path):
# Ensure destination directory exists
os.makedirs(destination_dir, exist_ok=True)
# Extract files from tar.gz file
with tarfile.open(source_file, "r:gz") as tar:
for member in tar.getmembers():
if member.name.startswith(extract_path):
tar.extract(member, destination_dir)
def main():
# Source file pattern
source_pattern = "/mnt/server_backup/restore/*.tar.gz"
# Destination directory
destination_dir = "/home/ccalifice/"
# Path inside the tarfile to extract
extract_path = "home/ccalifce/"
# Get list of tar.gz files
tar_files = glob.glob(source_pattern)
if not tar_files:
print("No matching tar.gz files found.")
return
# Copy and extract each tar.gz file
for source_file in tar_files:
try:
extract_tar_gz(source_file, destination_dir, extract_path)
print(f"Extraction successful for {source_file}.")
except Exception as e:
print(f"Error extracting {source_file}: {e}")
if __name__ == "__main__":
main()