Last active
February 7, 2018 16:47
-
-
Save denizozger/d74c99a765bd78840cb957f5ad4f08d7 to your computer and use it in GitHub Desktop.
Copy home directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import zipfile | |
FOLDERS_TO_EXCLUDE = ['Applications', 'Downloads', 'Movies', 'Music', 'Public', 'node_modules'] | |
def zipdir(path, ziph): | |
for root, dirs, files in os.walk(path): | |
dirs[:] = [x for x in dirs if ( | |
x not in FOLDERS_TO_EXCLUDE) and (not x.startswith('.'))] | |
for file in files: | |
if not file.startswith('.'): | |
ziph.write(os.path.join(root, file)) | |
ziph.write('/Users/denizozger/Library/Application Support/Code/User/settings.json') | |
ziph.write('/Users/denizozger/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings') | |
ziph.write('/Users/denizozger/.bash_profile') | |
if __name__ == '__main__': | |
zipf = zipfile.ZipFile('deniz_backup.zip', 'w', zipfile.ZIP_DEFLATED) | |
zipdir('/Users/denizozger', zipf) | |
zipf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment