Advertisement
Guest User

Untitled

a guest
Apr 18th, 2023
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import os
  2. import sys
  3. import pandas as pd
  4. from subprocess import call
  5.  
  6. def main():
  7. if len(sys.argv) != 4:
  8. print("Usage: python lightroom_borgbackup.py <csv_file> <repo_path> <backup_name>")
  9. return
  10.  
  11. csv_file = sys.argv[1]
  12. repo_path = sys.argv[2]
  13. backup_name = sys.argv[3]
  14.  
  15. # Read the CSV file
  16. df = pd.read_csv(csv_file)
  17.  
  18. # Filter RAW files
  19. df = df[df['File Name'].str.endswith(('.CR2', '.NEF', '.DNG', '.ARW'))]
  20.  
  21. # Create a list of files to backup
  22. files_to_backup = df['File Path'].tolist()
  23.  
  24. # Create a temporary file with the list of files
  25. with open('files_to_backup.txt', 'w') as f:
  26. f.write('\n'.join(files_to_backup))
  27.  
  28. # Invoke borgbackup
  29. call(['borg', 'create', '--files-from', 'files_to_backup.txt', f'{repo_path}::{backup_name}', '.'])
  30.  
  31. # Remove the temporary file
  32. os.remove('files_to_backup.txt')
  33.  
  34. if __name__ == "__main__":
  35. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement