问题
I was trying to back up my whole computer drive to google cloud storage, people mainly told me that was nonsensical, and while pondering it all, I decided just to do documents and desktop, and my goal was to use the google cloud SDK as I'm new to this and I like a challenge. So I type in:
gsutil -m rsync -n -J -C -e -r -u -U C:\Users\~~~~\Documents gs://~~~~-pc/documents
When I send that, I receive this message:
Caught non-retryable exception while listing file://C:\Users~~~~~\Documents: [WinError 3] The system cannot find the path specified: 'C:\Users\~~~~~\Documents\~~~~~~~~~ Files\2015 NEGOTIATIONIS\2105 NEGOTIATIONS FILE - MAIN\Implementation\Temporary Transfers and Permanet Involuntary Force Rearragement\Temporary Transfers and Permanent Involuntary Force Rearrangement FINAL October 3 2014.docx' CommandException: Caught non-retryable exception - aborting rsync
Please Help!!!
Note: "~" is for censorship
Edit: I did a debug, and I don't know what anything meant, here's an output that doesn't show my personal data:
Caught non-retryable exception while listing file://C:\Users\~~~~\Documents: [WinError 3] The system cannot find the path specified: 'C:\\Users\\~~~~\\Documents\\~~~~ Files\\2015 NEGOTIATIONIS\\2105 NEGOTIATIONS FILE - MAIN\\Implementation\\Temporary Transfers and Permanet Involuntary Force Rearragement\\Temporary Transfers and Permanent Involuntary Force Rearrangement FINAL October 3 2014.docx'
Traceback (most recent call last):
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\commands\rsync.py", line 653, in _ListUrlRootFunc
out_file)
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\commands\rsync.py", line 903, in _BatchSort
current_chunk = sorted(islice(in_iter, buffer_size))
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\commands\rsync.py", line 734, in _FieldedListingIterator
for blr in iterator:
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\wildcard_iterator.py", line 701, in IterObjects
bucket_listing_fields=bucket_listing_fields):
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\wildcard_iterator.py", line 721, in IterAll
bucket_listing_fields=bucket_listing_fields):
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\wildcard_iterator.py", line 611, in __iter__
blr_object = _GetFileObject(filepath) if include_size else None
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\wildcard_iterator.py", line 531, in _GetFileObject
return apitools_messages.Object(size=os.path.getsize(filepath))
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\lib\genericpath.py", line 50, in getsize
return os.stat(filename).st_size
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\~~~~\\Documents\\~~~~ Files\\2015 NEGOTIATIONIS\\2105 NEGOTIATIONS FILE - MAIN\\Implementation\\Temporary Transfers and Permanet Involuntary Force Rearragement\\Temporary Transfers and Permanent Involuntary Force Rearrangement FINAL October 3 2014.docx'
DEBUG: Exception stack trace:
Traceback (most recent call last):
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\__main__.py", line 634, in _RunNamedCommandAndHandleExceptions
user_project=user_project)
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\command_runner.py", line 411, in RunNamedCommand
return_code = command_inst.RunCommand()
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\commands\rsync.py", line 1657, in RunCommand
diff_iterator = _DiffIterator(self, src_url, dst_url)
File "C:\Users\~~~~\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\gsutil\gslib\commands\rsync.py", line 999, in __init__
raise CommandException('Caught non-retryable exception - aborting rsync')
gslib.exception.CommandException: CommandException: Caught non-retryable exception - aborting rsync
回答1:
Your problem is caused by MAX_PATH. The default is 260 characters.
Method 1 - Specify UNC Paths
Prefix paths with "\\?\"
. This changes maximum path names to 32,767 characters.
\\?\C:\Users\~~~~\Documents
Method 2 - Change the Windows Registry
To solve your problem requires editing the registry to support longer path names up to 32,767 characters.
Change this registry key:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled
Type: REG_DWORD
Value: 1
Read this document for more information:
Enable Long Paths in Windows 10, Version 1607, and Later
来源:https://stackoverflow.com/questions/65278353/how-to-avoid-files-that-are-not-found-winerror-3