# Mega Backups fails (+ MFA Setup)

**URL:** https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439
**Category:** Uncategorized
**Created:** [July 2, 2023, 8:46am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439 "2023-07-02T08:46:22Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Unpledged3967](https://forum.duplicati.com/user_avatar/forum.duplicati.com/unpledged3967/32/8277_2.png) [@Unpledged3967](https://forum.duplicati.com/u/Unpledged3967)
#### Post date: [July 2, 2023, 8:46am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/1 "2023-07-02T08:46:22Z")

</div>

Hi there  
I’m currently running 2.0.7.1\_beta\_2023-05-25 and just now received the report, that one of my backups failed.  
It’s a backup of a local directory to Mega (with the “new” MFA option set). On Friday (2 days ago) it worked without a problem, now it doesn’t.

Just a few minutes ago I received the error message “At least one error has occurred.” Unfortunately, there is no entry in the log for the backup-attempt at all.

I created a third backup to the same mega and it works without a problem.

I tried to verify files, repairing the database, recreating the database and all of them ran without any errors.

I tested around quite a lot and the problem seems to be linked to 3 video files. Without them in the source, the backup works. The files are 423MB, 353MB and 387MB of size.  
It’s no problem related to the left storage of the account I used, I tried with my other account that has 30GB of storage left too, same problem.

 ![2023-07-02 09_39_40-](https://forum.duplicati.com/uploads/default/original/2X/6/6eeaa27251f9f173c03cd5de998befb54f10e65d.png)

---

<div class="post-metadata">

### Author: ![gpatel-fr](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/g/7993a0/32.png) [@gpatel-fr](https://forum.duplicati.com/u/gpatel-fr)
#### Post date: [July 2, 2023, 9:27am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/2 "2023-07-02T09:27:03Z")

</div>

> [@Unpledged3967](#):
>
> Unfortunately, there is no entry in the log for the backup-attempt at all.

Hello

please try to gather more information since as it is there is not much to go on.

For that, you can export the job as command line, open a terminal (in admin mode if you are running Duplicati as a service) and paste the export into it, add the flag --console-log-level=verbose, then run it.

When it has crashed, copy, say, the 200 preceding lines, zip them and attach the result to a reply.

---

<div class="post-metadata">

### Author: ![Jojo-1000](https://forum.duplicati.com/user_avatar/forum.duplicati.com/jojo-1000/32/8262_2.png) [@Jojo-1000](https://forum.duplicati.com/u/Jojo-1000)
#### Post date: [July 2, 2023, 9:40am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/3 "2023-07-02T09:40:51Z")

</div>

> [@Unpledged3967](#):
>
> Unfortunately, there is no entry in the log for the backup-attempt at all

In the server log (on the about page) there should at least be the error message that caused the failure.

---

<div class="post-metadata">

### Author: ![Unpledged3967](https://forum.duplicati.com/user_avatar/forum.duplicati.com/unpledged3967/32/8277_2.png) [@Unpledged3967](https://forum.duplicati.com/u/Unpledged3967)
#### Post date: [July 2, 2023, 10:01am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/4 "2023-07-02T10:01:31Z")

</div>

Seems to be related to the API “ResourceExpired”

[Jul 2, 2023 1218 PM Failed while executing Backup with id 1.zip](https://forum.duplicati.com/uploads/short-url/i5T8swYOnNyvXfV8f0Kb0Gn6xz9.zip) (20.9 KB)

---

<div class="post-metadata">

### Author: ![Unpledged3967](https://forum.duplicati.com/user_avatar/forum.duplicati.com/unpledged3967/32/8277_2.png) [@Unpledged3967](https://forum.duplicati.com/u/Unpledged3967)
#### Post date: [July 2, 2023, 10:42am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/5 "2023-07-02T10:42:32Z")

</div>

Thank you for you answer.  
Here is the Output:  
I recorded the whole output, if you need more than the last 200 lines, I’ll need to censore them but can get you them.  
“ResourceExpired” as API response seems to be related

Here they are  
[output log.zip](https://forum.duplicati.com/uploads/short-url/qPV1tDqV63NdXukQsnxgSNnKrrp.zip) (16.7 KB)

---

<div class="post-metadata">

### Author: ![Jojo-1000](https://forum.duplicati.com/user_avatar/forum.duplicati.com/jojo-1000/32/8262_2.png) [@Jojo-1000](https://forum.duplicati.com/u/Jojo-1000)
#### Post date: [July 2, 2023, 11:07am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/6 "2023-07-02T11:07:23Z")

</div>

This issue had the same error and stack trace, but it was said to be resolved with an update:

> <https://github.com/duplicati/duplicati/issues/3773>
>
> \- \[x\] I have searched open and closed issues for duplicates.
> 
> \----------------…------------------------
> 
> \## Environment info
> 
> 
> \- \*\*Duplicati version\*\*: 2.0.4.5\_beta\_2018-11-28
> \- \*\*Operating system\*\*: Ubuntu 18 
> \- \*\*Backend\*\*: mega.nz
> 
> \## Description
> 
> When testing the connection to mega.nz I get the error "ResourceExpired"
> 
> \## Steps to reproduce
> 
> 1. Add a backup with the storage type mega.nz
> 2. Provide your login and test the connection
> 
> 
> 
> \- \*\*Actual result\*\*:
> error
> \- \*\*Expected result\*\*:
> success
> 
> \## Debug log
> 
> 
> \`\`\`
> CG.Web.MegaApiClient.ApiException: API response: ResourceExpired
> at CG.Web.MegaApiClient.MegaApiClient.RequestCore\[TResponse\] (CG.Web.MegaApiClient.Serialization.RequestBase request, System.Byte\[\] key) \[0x00132\] in \<b77b6a46b6b94e008d0d458c52698090\>:0 
> at CG.Web.MegaApiClient.MegaApiClient.Request\[TResponse\] (CG.Web.MegaApiClient.Serialization.RequestBase request, System.Byte\[\] key) \[0x00024\] in \<b77b6a46b6b94e008d0d458c52698090\>:0 
> at CG.Web.MegaApiClient.MegaApiClient.Login (CG.Web.MegaApiClient.MegaApiClient+AuthInfos authInfos) \[0x00037\] in \<b77b6a46b6b94e008d0d458c52698090\>:0 
> at CG.Web.MegaApiClient.MegaApiClient.Login (System.String email, System.String password) \[0x00009\] in \<b77b6a46b6b94e008d0d458c52698090\>:0 
> at Duplicati.Library.Backend.Mega.MegaBackend.get\_Client () \[0x0000e\] in \<b4f95326982b44b59db3ece5ce06b53b\>:0 
> at Duplicati.Library.Backend.Mega.MegaBackend.GetCurrentFolder (System.Boolean autocreate) \[0x00020\] in \<b4f95326982b44b59db3ece5ce06b53b\>:0 
> at Duplicati.Library.Backend.Mega.MegaBackend.ResetFileCache (System.Collections.Generic.IEnumerable\`1\[T\] list) \[0x00008\] in \<b4f95326982b44b59db3ece5ce06b53b\>:0 
> at Duplicati.Library.Backend.Mega.MegaBackend.List () \[0x00008\] in \<b4f95326982b44b59db3ece5ce06b53b\>:0 
> at Duplicati.Library.Interface.BackendExtensions.TestList (Duplicati.Library.Interface.IBackend backend) \[0x00000\] in \<cad0aa948bd5428e9683582f0d34e521\>:0 
> at Duplicati.Library.Backend.Mega.MegaBackend.Test () \[0x00000\] in \<b4f95326982b44b59db3ece5ce06b53b\>:0 
> at Duplicati.Server.WebServer.RESTMethods.RemoteOperation.TestConnection (System.String url, Duplicati.Server.WebServer.RESTMethods.RequestInfo info) \[0x000b7\] in \<fe28905ee30b422e8d475f1cfdb85515\>:0 
> at Duplicati.Server.WebServer.RESTMethods.RemoteOperation.POST (System.String key, Duplicati.Server.WebServer.RESTMethods.RequestInfo info) \[0x00091\] in \<fe28905ee30b422e8d475f1cfdb85515\>:0 
> at Duplicati.Server.WebServer.RESTHandler.DoProcess (Duplicati.Server.WebServer.RESTMethods.RequestInfo info, System.String method, System.String module, System.String key) \[0x00280\] in \<fe28905ee30b422e8d475f1cfdb85515\>:0 
> \`\`\`

There is also this forum post:

> [@Mega.nz error when check connection](https://forum.duplicati.com/t/mega-nz-error-when-check-connection/5316):
>
> If i try to define a Mega.nz backup destination I get error when click on “check connection” that says: Failed to connect: API response: ResourceExpired In Duplicati log appears message: Request for [http://localhost:8200/api/v1/remoteoperation/test](http://localhost:8200/api/v1/remoteoperation/test) gave error CG.Web.MegaApiClient.ApiException: API response: ResourceExpired en CG.Web.MegaApiClient.MegaApiClient.RequestCore[TResponse](RequestBase request, Byte key) en CG.Web.MegaApiClient.MegaApiClient.Request[TResponse](RequestBase request, …

Neither of those seem to indicate a connection to the file sizes, but maybe nobody ever noticed. If you can reliably reproduce the error, you might be up to something.

It might help others to reproduce if you post your job configuration (without passwords and other sensitive data).

---

<div class="post-metadata">

### Author: ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)
#### Post date: [July 2, 2023, 1:20pm UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/7 "2023-07-02T13:20:30Z")

</div>

> [@Unpledged3967](#):
>
> I recorded the whole output, if you need more than the last 200 lines, I’ll need to censore them

Maybe you could look at it to see if `Backend event: Put` worked for awhile, before error section.  
Or if you can see file dates in MEGA, see how long new ones were going up.

> [@Unpledged3967](#):
>
> with the “new” MFA option set

Maybe the quotes around “new” mean two years old, but maybe Canary didn’t give it much testing.

[2.0.6.100\_canary\_2021-08-11](https://github.com/duplicati/duplicati/releases/tag/v2.0.6.100-2.0.6.100_canary_2021-08-11)

> Added support for mega.nz 2fa, thanks [@vfrz](https://github.com/vfrz)

```plaintext
  --auth-two-factor-key (Password): The shared secret used to generate
    two-factor TOTP codes.
    For accounts with two-factor authentication enabled, this is the shared
    secret used to generate the two-factor TOTP codes.

```

and it seemingly does really mean the original shared secret, not usual 6 digit time based code.  
I see it generates the code before giving it to MEGA. Does the system time here seem correct?

If any of the failing accounts doesn’t use 2FA, then that’s a good way to kill this line of inquiry…

Problem is that it’s rather unclear what’s going on. There’s a reverse-engineered protocol done  
from a third party library – and MEGA support generally doesn’t want to even start with support.

There are a few similar uses, one major one used by rclone, and I’m not finding such problems.  
I did find a complaint about concurrent uploads, so especially after you had some early uploads  
[asynchronous-concurrent-upload-limit](https://duplicati.readthedocs.io/en/latest/06-advanced-options/#asynchronous-concurrent-upload-limit) set to 1 instead of its default 4 might possibly avoid issue.

It might be best to set `--auth-two-factor-key` option on Screen 5 too. Screen 2 loses options.  
[Fix bug that removes advanced target options when editing backups #4972](https://github.com/duplicati/duplicati/pull/4972) PR means to fix this.

When option is on Destination screen 2, you could seize opportunity to [Export As Command-line](https://duplicati.readthedocs.io/en/latest/03-using-the-graphical-user-interface/#exporting-a-backup-job-configuration).  
[Duplicati.CommandLine.BackendTool.exe](https://duplicati.readthedocs.io/en/latest/07-other-command-line-utilities/#duplicaticommandlinebackendtoolexe) and [Duplicati.CommandLine.BackendTester.exe](https://duplicati.readthedocs.io/en/latest/07-other-command-line-utilities/#duplicaticommandlinebackendtesterexe) could  
use the target URL (maybe edited to a different folder, and automatic `Test` will insist on having it).

---

<div class="post-metadata">

### Author: ![gpatel-fr](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/g/7993a0/32.png) [@gpatel-fr](https://forum.duplicati.com/u/gpatel-fr)
#### Post date: [July 2, 2023, 5:54pm UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/8 "2023-07-02T17:54:46Z")

</div>

> [@Unpledged3967](#):
>
> I recorded the whole output, if you need more than the last 200 lines

It’s true that the error begins before - I did not take in account the retryings when I asked for the last 200 lines. Anyway it’s possible that there is not much more interesting data before. If it’s the case it could be interesting to follow all the good advice you received, particularly posting your job config - did you by any chance raise the maximum file size above the default value of 50 MB ? If yes the problem could be that you are simply suffering from a time out due to too big blocks. There is often a maximum time for a single Http transfer (PUT).

Edit: I forgot to say that the advanced option for that in Duplicati is only active if Duplicati is managing the Http transfer itself. When there is an external third party driver, the option needs to be passed by specific API - something that don’t seem to be done currently.

---

<div class="post-metadata">

### Author: ![Unpledged3967](https://forum.duplicati.com/user_avatar/forum.duplicati.com/unpledged3967/32/8277_2.png) [@Unpledged3967](https://forum.duplicati.com/u/Unpledged3967)
#### Post date: [July 2, 2023, 9:35pm UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/9 "2023-07-02T21:35:17Z")

</div>

> [@Jojo-1000](#):
>
> If you can reliably reproduce the error, you might be up to something.

I was able to reproduce it for the last 2 days. Just to confirm again, I just ran the backup again and… it worked without any problem. Even tried creating copies of the previously problematic files, but the backup worked anyway. I’ll try to replicate it in the next few days.

> [@Jojo-1000](#):
>
> It might help others to reproduce if you post your job configuration

Here you go (I hope that’s what you meant.):

```plaintext
"C:\Program Files\Duplicati 2\Duplicati.CommandLine.exe" backup "mega://duplicati/gdrive?auth-username=username%40gmail.com&auth-two-factor-key=donteventryit" "C:\Users\Username\Google Drive(username@gmail.com)\\" --backup-name="Google Drive" --dbpath="C:\Users\Username\AppData\Local\Duplicati\GXEPBEUIUA.sqlite" --encryption-module=aes --compression-module=zip --dblock-size=50mb --retention-policy="30D:1D,5W:1W,12M:1M,99Y:1Y" --disable-module=console-password-input

```

> [@ts678](#):
>
> Maybe you could look at it to see if `Backend event: Put` worked for awhile, before error section.  
> Or if you can see file dates in MEGA, see how long new ones were going up.

Will do once the error occurs again.

> [@ts678](#):
>
> If any of the failing accounts doesn’t use 2FA

I’ll try disabling MFA once the problem comes up again.

> [@gpatel-fr](#):
>
> did you by any chance raise the maximum file size above the default value of 50 MB ?

nope. I left it to default 50MB.

Thank you for all your help.  
I’m sorry that I don’t know how to provide any lead on what caused the problem.  
From what I’ve found so fare regarding problems with Duplicati, Mega doesn’t seem to be a good choice for a backup target. I’m using it, as I’ve got a grandfathered 50GB Free account.

---

<div class="post-metadata">

### Author: ![gpatel-fr](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/g/7993a0/32.png) [@gpatel-fr](https://forum.duplicati.com/u/gpatel-fr)
#### Post date: [July 2, 2023, 10:16pm UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/10 "2023-07-02T22:16:05Z")

</div>

I just tried it with my test install for next Duplicati (it uses the same Mega driver than current Beta) and succeeded with a 480 MB file so it’s not a general problem (however I did not try it with 2FA - I have no idea how to use this, I have only setup a test account with Mega to test Duplicati)

---

<div class="post-metadata">

### Author: ![Unpledged3967](https://forum.duplicati.com/user_avatar/forum.duplicati.com/unpledged3967/32/8277_2.png) [@Unpledged3967](https://forum.duplicati.com/u/Unpledged3967)
#### Post date: [July 3, 2023, 5:10am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/11 "2023-07-03T05:10:35Z")

</div>

Yeah I dont know.  
This is my second post screaming for help - last time the transfer limit of Mega was reached for some reason. (I guess due to my ISP cycling public IPs on a daily basis)

Anyway, here is a short guide on how to use Mega with MFA multi factor authentication with Duplicati:

1. Set-up MFA in Mega in the [security part of settings](https://mega.nz/fm/account/security) and copy the seed code that is shown to you.  
1a. If you already have it activated and use a non-shit MFA Tool you can also derive this from the TOTP: `otpauth://totp/MEGA:*username*@*provider*.com?secret=herewouldbeacodethatyouneedtocopy&issuer=MEGA` →   
**herewouldbeacodethatyouneedtocopy**

2. In the second step (Destination) of the duplicati backup setup, once needs to enter the credentials and expand the advanced options. In the dropdown, select the option auth-two-factor-key and enter the previously copied herewouldbeacodethatyouneedtocopy into the new field.  

3. Test the connection and see whether you were successful.

---

<div class="post-metadata">

### Author: ![gpatel-fr](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/g/7993a0/32.png) [@gpatel-fr](https://forum.duplicati.com/u/gpatel-fr)
#### Post date: [July 3, 2023, 5:58am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/12 "2023-07-03T05:58:39Z")

</div>

Yeah there is something rotten with 2FA. I test the connection and it is ‘successful’, yet trying to do a backup (empty, never mind a 400 Mb file) fails immediately. I can see the code in FreeOtp+ and it’s the same as in Duplicati :-/. Trying a second time, backup succeeds yet I can see retries in the live log, even for small files.  
Removed 2FA and an empty backup succeeds without retry (it is always doing a download of at least 50 Mb file for verification purpose).  
For the sake of research, if you disable 2FA, does it succeeds ?

---

<div class="post-metadata">

### Author: ![Unpledged3967](https://forum.duplicati.com/user_avatar/forum.duplicati.com/unpledged3967/32/8277_2.png) [@Unpledged3967](https://forum.duplicati.com/u/Unpledged3967)
#### Post date: [July 3, 2023, 6:00am UTC](https://forum.duplicati.com/t/mega-backups-fails-mfa-setup/16439/13 "2023-07-03T06:00:21Z")

</div>

> [@gpatel-fr](#):
>
> For the sake of research, if you disable 2FA, does it succeeds

As currently the backup just works, I cant test it right now. But I will keep trying to replicate the behavior.
