jtpio / trello-full-backup

Python script to backup everything from Trello: boards, lists, cards and attachments
MIT License
123 stars 36 forks source link

card.json missing (compose, powershell) #7

Open dbonattoj opened 7 years ago

dbonattoj commented 7 years ago

I got this error when I try to backup my trello.

[36mtrello_1  |[0m Saving 2_How to make a _ when to _ What is a practical way of doing 
[36mtrello_1  |[0m Saving card.json and description.md
[36mtrello_1  |[0m Traceback (most recent call last):
[36mtrello_1  |[0m   File "/usr/local/bin/trello-full-backup", line 11, in <module>
[36mtrello_1  |[0m     sys.exit(main())
[36mtrello_1  |[0m   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/__init__.py", line 5, in main
[36mtrello_1  |[0m     cli()
[36mtrello_1  |[0m   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 247, in cli
[36mtrello_1  |[0m     backup_board(board, args)
[36mtrello_1  |[0m   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 141, in backup_board
[36mtrello_1  |[0m     backup_card(id_card, c, args.attachment_size)
[36mtrello_1  |[0m   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 91, in backup_card
[36mtrello_1  |[0m     write_file(meta_file_name, c)
[36mtrello_1  |[0m   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 33, in write_file
[36mtrello_1  |[0m     with open(file_name, 'w', encoding='utf-8') as f:
[36mtrello_1  |[0m FileNotFoundError: [Errno 2] No such file or directory: 'card.json'
[36mtrellofullbackup_trello_1 exited with code 1

I'm using docker-compose:

version: '2'
services:
  trello:
    image: trello_bck
    build: .
    volumes:
      - ./backups:/app
    environment:
      - TRELLO_API_KEY=1234
      - TRELLO_TOKEN=5678

And a powershell script to run the backups with a scheduler (work in progress):

# Script to automatically save trello

Set-ExecutionPolicy Unrestricted

Set-Location -Path $pwd

docker-compose up
docker-compose down

Several files are written on disk, and they have content. eg:

me/my_board/my_board_full.json me/my_board/0_list/0_card/card.json me/my_board/0_list/0_card/description.json me/my_board/0_list/0_card/attachments/the_attachments_are_ok

Any idea? thanks

jtpio commented 7 years ago

Thanks for reporting the error, but I couldn't reproduce on Linux. Do you get the same issue without using the powershell script (docker-compose up --build)?

dbonattoj commented 7 years ago

Yes exactly the same problem.

I've also tried to put everything in C:/Users/user/document/project (user space) instead of D:/project and the docker client is well configured to have access to them.

image

But this does not change anything.

> docker-compose up
Creating trellofullbackup_trello_1
Attaching to trellofullbackup_trello_1
trello_1  | ==== Backup initiated
trello_1  | Backing up to: 2017-05-08_12-59-13_backup
trello_1  | Backup closed board: False
trello_1  | Backup archived lists: False
trello_1  | Backup archived cards: False
trello_1  | Attachment size limit (bytes): 100000000
trello_1  | ====
trello_1  |
trello_1  | Saving full json for board BJJ with id 1234 to BJJ_full.json
trello_1  | Saving 0_Mount position
trello_1  | Saving card.json and description.md
trello_1  | Saving full json for board Mym with id 1234 to Mym_full.json
trello_1  | Saving 0_Types de ressources
trello_1  | Saving card.json and description.md
trello_1  | Saving 1_Objecti
trello_1  | Saving card.json and description.md
trello_1  | Saving 0_SI
trello_1  | Saving card.json and description.md
trello_1  | Saving attachment 0_ia.pdf
trello_1  | Saving attachment 1_SI.png
trello_1  | Saving 1_Pref SI
trello_1  | Saving card.json and description.md
trello_1  | Saving attachment 0_pref SI.png
trello_1  | Saving 2_Alph c
trello_1  | Saving card.json and description.md
trello_1  | Saving attachment 0_Alph_c.png
trello_1  | Saving 2_How to m
trello_1  | Saving card.json and description.md
trello_1  | Traceback (most recent call last):
trello_1  |   File "/usr/local/bin/trello-full-backup", line 11, in <module>
trello_1  |     sys.exit(main())
trello_1  |   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/__init__.py", line 5, in main
trello_1  |     cli()
trello_1  |   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 247, in cli
trello_1  |     backup_board(board, args)
trello_1  |   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 141, in backup_board
trello_1  |     backup_card(id_card, c, args.attachment_size)
trello_1  |   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 91, in backup_card
trello_1  |     write_file(meta_file_name, c)
trello_1  |   File "/usr/local/lib/python3.6/site-packages/trello_full_backup/backup.py", line 33, in write_file
trello_1  |     with open(file_name, 'w', encoding='utf-8') as f:
trello_1  | FileNotFoundError: [Errno 2] No such file or directory: 'card.json'
trellofullbackup_trello_1 exited with code 1

The folders/files created are approximately like this: tree /f > tree.txt image

Every "card.json" is there UNTIL a card with a very long name:

How to make a good schedule ? when to study again/test ourself ? What is a practical way of doing so, using memory cards? direct from the book?

When I check the created folders I have:

2How to make a good schedule when to study againtest ourself What is a practical way of doing

WITH this symbol: "" And this folder is effectively empty. I think the problem is there.

I had the same problem previously with the how to use trello for android board, which I deleted.

EDIT: I have successfully backed up my trello by splitting this card, however the bug should be removed. I think that the "sanitize_file_name" function is not bullet proof. Another idea is to let the user the possibility to make folders following the shortlink or the id of the card. It is easier to use in other scripts.

Best regards,

jtpio commented 7 years ago

The long name seems to be the root of the issue indeed. The sanitize_file_name function can be fixed. Otherwise PR #9 will help with the support of short links.