-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(backup): add more destination types support #3756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,29 +40,74 @@ export const destinationRouter = createTRPCRouter({ | |||||||||||||||||||
| }); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }), | ||||||||||||||||||||
| // Non-S3 providers that use rclone native protocols | ||||||||||||||||||||
| const NON_S3_PROVIDERS = [ | ||||||||||||||||||||
| "ftp", "sftp", "drive", "onedrive", "dropbox", "webdav", | ||||||||||||||||||||
| "b2", "mega", "pcloud", "box", "hubic", "yandex" | ||||||||||||||||||||
| ]; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| testConnection: adminProcedure | ||||||||||||||||||||
| .input(apiCreateDestination) | ||||||||||||||||||||
| .mutation(async ({ input }) => { | ||||||||||||||||||||
| const { secretAccessKey, bucket, region, endpoint, accessKey, provider } = | ||||||||||||||||||||
| input; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Check if it's a non-S3 provider | ||||||||||||||||||||
| const isNonS3 = provider && NON_S3_PROVIDERS.includes(provider); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try { | ||||||||||||||||||||
| const rcloneFlags = [ | ||||||||||||||||||||
| `--s3-access-key-id="${accessKey}"`, | ||||||||||||||||||||
| `--s3-secret-access-key="${secretAccessKey}"`, | ||||||||||||||||||||
| `--s3-region="${region}"`, | ||||||||||||||||||||
| `--s3-endpoint="${endpoint}"`, | ||||||||||||||||||||
| "--s3-no-check-bucket", | ||||||||||||||||||||
| "--s3-force-path-style", | ||||||||||||||||||||
| "--retries 1", | ||||||||||||||||||||
| "--low-level-retries 1", | ||||||||||||||||||||
| "--timeout 10s", | ||||||||||||||||||||
| "--contimeout 5s", | ||||||||||||||||||||
| ]; | ||||||||||||||||||||
| if (provider) { | ||||||||||||||||||||
| rcloneFlags.unshift(`--s3-provider="${provider}"`); | ||||||||||||||||||||
| let rcloneCommand: string; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (isNonS3) { | ||||||||||||||||||||
| // Non-S3 providers use rclone native protocols | ||||||||||||||||||||
| const providerConfig: Record<string, string> = { | ||||||||||||||||||||
| ftp: `:ftp:${bucket || ""}`, | ||||||||||||||||||||
| sftp: `:sftp:${bucket || ""}`, | ||||||||||||||||||||
| drive: `:drive:${bucket || ""}`, | ||||||||||||||||||||
| onedrive: `:onedrive:${bucket || ""}`, | ||||||||||||||||||||
| dropbox: `:dropbox:${bucket || ""}`, | ||||||||||||||||||||
| webdav: `:webdav:${bucket || ""}`, | ||||||||||||||||||||
| b2: `:b2:${bucket || ""}`, | ||||||||||||||||||||
| mega: `:mega:${bucket || ""}`, | ||||||||||||||||||||
| pcloud: `:pcloud:${bucket || ""}`, | ||||||||||||||||||||
| box: `:box:${bucket || ""}`, | ||||||||||||||||||||
| hubic: `:hubic:${bucket || ""}`, | ||||||||||||||||||||
| yandex: `:yandex:${bucket || ""}`, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
Comment on lines
+61
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. several providers (Google Drive, OneDrive, Dropbox, Box) require OAuth authentication flow, not simple username/password. the current implementation using |
||||||||||||||||||||
|
|
||||||||||||||||||||
| const rcloneFlags = [ | ||||||||||||||||||||
| "--retries 1", | ||||||||||||||||||||
| "--low-level-retries 1", | ||||||||||||||||||||
| "--timeout 10s", | ||||||||||||||||||||
| "--contimeout 5s", | ||||||||||||||||||||
| ]; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Add authentication if provided | ||||||||||||||||||||
| if (accessKey) rcloneFlags.push(`--${provider}-user="${accessKey}"`); | ||||||||||||||||||||
| if (secretAccessKey) rcloneFlags.push(`--${provider}-pass="${secretAccessKey}"`); | ||||||||||||||||||||
| if (endpoint) rcloneFlags.push(`--${provider}-url="${endpoint}"`); | ||||||||||||||||||||
|
Comment on lines
+86
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rclone flag format |
||||||||||||||||||||
|
|
||||||||||||||||||||
| rcloneCommand = `rclone ls ${rcloneFlags.join(" ")} "${providerConfig[provider]}"`; | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing type safety: accessing
Suggested change
|
||||||||||||||||||||
| } else { | ||||||||||||||||||||
| // S3 compatible providers | ||||||||||||||||||||
| const rcloneFlags = [ | ||||||||||||||||||||
| `--s3-access-key-id="${accessKey}"`, | ||||||||||||||||||||
| `--s3-secret-access-key="${secretAccessKey}"`, | ||||||||||||||||||||
| `--s3-region="${region}"`, | ||||||||||||||||||||
| `--s3-endpoint="${endpoint}"`, | ||||||||||||||||||||
| "--s3-no-check-bucket", | ||||||||||||||||||||
| "--s3-force-path-style", | ||||||||||||||||||||
| "--retries 1", | ||||||||||||||||||||
| "--low-level-retries 1", | ||||||||||||||||||||
| "--timeout 10s", | ||||||||||||||||||||
| "--contimeout 5s", | ||||||||||||||||||||
| ]; | ||||||||||||||||||||
| if (provider) { | ||||||||||||||||||||
| rcloneFlags.unshift(`--s3-provider="${provider}"`); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| const rcloneDestination = `:s3:${bucket}`; | ||||||||||||||||||||
| rcloneCommand = `rclone ls ${rcloneFlags.join(" ")} "${rcloneDestination}"`; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| const rcloneDestination = `:s3:${bucket}`; | ||||||||||||||||||||
| const rcloneCommand = `rclone ls ${rcloneFlags.join(" ")} "${rcloneDestination}"`; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (IS_CLOUD && !input.serverId) { | ||||||||||||||||||||
| throw new TRPCError({ | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid syntax: constant declaration inside router object definition will cause compilation error