Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import pandas as pd
- from subprocess import call
- def main():
- if len(sys.argv) != 4:
- print("Usage: python lightroom_borgbackup.py <csv_file> <repo_path> <backup_name>")
- return
- csv_file = sys.argv[1]
- repo_path = sys.argv[2]
- backup_name = sys.argv[3]
- # Read the CSV file
- df = pd.read_csv(csv_file)
- # Filter RAW files
- df = df[df['File Name'].str.endswith(('.CR2', '.NEF', '.DNG', '.ARW'))]
- # Create a list of files to backup
- files_to_backup = df['File Path'].tolist()
- # Create a temporary file with the list of files
- with open('files_to_backup.txt', 'w') as f:
- f.write('\n'.join(files_to_backup))
- # Invoke borgbackup
- call(['borg', 'create', '--files-from', 'files_to_backup.txt', f'{repo_path}::{backup_name}', '.'])
- # Remove the temporary file
- os.remove('files_to_backup.txt')
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement