ilmal / Server-hosting.old

0 stars 0 forks source link

adding backup to mongodb #53

Open ilmal opened 2 years ago

ilmal commented 2 years ago

https://docs.mongodb.com/manual/core/backups/

example: python script to dump mongodb and zip it up together with server files

ilmal commented 2 years ago

https://thispointer.com/python-how-to-create-a-zip-archive-from-multiple-files-or-directory/

ilmal commented 2 years ago

working py script `import shutil import zipfile import os

target_folder = "test_folder" output_name = "test_folder.zip"

if target_folder in os.listdir("."): shutil.rmtree(target_folder)

os.mkdir(target_folder)

for file in os.listdir("."): if file.startswith("."): print("File: " + file + "start with . (skipping)") continue if not file.startswith("test"): print("File: " + file + " don't start with test") continue if not file.endswith(".test"): print("File: " + file + " don't end with test") continue print("File: " + file + " is correct") shutil.copy("./" + file, target_folder)

if output_name in os.listdir("."): os.remove(output_name)

zip = zipfile.ZipFile(output_name, 'w', zipfile.ZIP_DEFLATED)

shutil.make_archive(target_folder, 'zip', target_folder) `

ilmal commented 2 years ago

Check what part of server files make up for the most size.

Check If vest solution is to only compress world folder.

Try the console command instead of python package.