NextCloud SNAP Backup Problems

Good day. Hopefully I can get some assistance with this. Let me state for the record that I (shamefully) have very limited Linux experience. Outside of the GUI versions of Debian/OpenSUSE/Ubuntu/Knoppix Iā€™ve got little to no experience - so any information sent may be met with a lot of questions.

The goal is to have a local backup with NextCloud which then is uploaded to a cloud storage service using WebDAV. The initial installation seems fine, but the problem seems to be with the backups. Apparently itā€™s causing problems with the setup and breaking NextCloud. Iā€™ll give some more details next. Information using the post template is given below. Any other information required - just ask and Iā€™ll do what I can.

It seems like the system just keeps creating backups without considering the available space. I had to clear /var/snap/nextcloud/common/nextcloud/data/ of all the other dated directories to get back 1.6TB of space. Once the space gets cluttered though, NextCloud shows this:

Cannot write into "apps" directory

This can usually be fixed by giving the webserver write access to the apps directory or disabling the App Store in the config file.

From here Iā€™ve tried to check the config.php and found that itā€™s basically blank (see below). It seems like I may need to reinstall once more, but Iā€™d need to find another way to push the files into the cloud storage since the backup seems to be breaking the system. This would be the 3rd time. I donā€™t mind doing it over, but it is time consuming.

Again - the goal is to have the local backup done for the systems - then have the files copied to a cloud storage using WebDAV.

I figure Iā€™ll have to reinstall (as I said before) since I canā€™t find the config file. I do have the settings.asc file, but no backup of the config.php. Not sure how to ā€œresumeā€ the backups from here, so will have to do it over from scratch once more.

Interestingly - I do have a 1TB drive which was in the box before upgrading to 2TB. That has all files and is totally full. I could pull files from that if needed to show what had happened before, so if you need any information from that - just ask.

A quick solution I think would be to just reinstall and then set up a CRON job to send the data directory to the cloud storage. From what Iā€™ve gathered, rClone should be able to get the job done. If anyone is available that would be willing to assist with that setup, Iā€™d be most appreciative.

Many thanks in advance. Hoping to get this resolved fully.

NextCloud version (23.0.3 / snap)
Operating system and version (Ubuntu 20.04.4 LTS)

The issue you are facing:

Is this the first time youā€™ve seen this error? (N):

Steps to replicate it:

  1. Install Ubuntu.
  2. Install NextCloud during Ubuntu setup (snap version) or through snap after OS install.
  3. Allocate 200GB per user (2TB storage).
  4. Setup backups to WebDAV storage.
  5. Leave it for a few days

The output of your Nextcloud log in Admin > Logging:

Unable to access NextCloud.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'abcdefg',
);

The output of your Apache/nginx/system log in /var/log/____:

Not sure where to find.

nextcloud.log

Lots of similar errors to this.

{"reqId":"abcdefg","level":3,"time":"2022-04-24T00:24:50+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"unlink(/tmp/phpZhl3al): No such file or directory at /var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Service/PointService.php#539","userAgent":"--","version":"23.0.3.2","exception":{"Exception":"Error","Message":"unlink(/tmp/phpZhl3al): No such file or directory at /var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Service/PointService.php#539","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Service/PointService.php","line":539,"function":"unlink"},{"file":"/var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Service/PointService.php","line":259,"function":"backupSql","class":"OCA\\Backup\\Service\\PointService","type":"->"},{"file":"/var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Cron/Backup.php","line":137,"function":"create","class":"OCA\\Backup\\Service\\PointService","type":"->"},{"file":"/var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Cron/Backup.php","line":124,"function":"runFullBackup","class":"OCA\\Backup\\Cron\\Backup","type":"->"},{"file":"/var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Cron/Backup.php","line":115,"function":"runBackup","class":"OCA\\Backup\\Cron\\Backup","type":"->"},{"file":"/var/snap/nextcloud/30258/nextcloud/extra-apps/backup/lib/Cron/Backup.php","line":97,"function":"manage","class":"OCA\\Backup\\Cron\\Backup","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/lib/private/BackgroundJob/Job.php","line":51,"function":"run","class":"OCA\\Backup\\Cron\\Backup","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/lib/private/BackgroundJob/TimedJob.php","line":58,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/cron.php","line":150,"function":"execute","class":"OC\\BackgroundJob\\TimedJob","type":"->"}],"File":"/snap/nextcloud/30258/htdocs/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}

And also.

{"reqId":"LSOCZhiI7s7yGBRm2tH8","level":4,"time":"2022-04-24T00:32:53+00:00","remoteAddr":"xxx.xxx.xxx.15","user":"USER","app":"webdav","method":"GET","url":"/remote.php/dav/avatars/USER/128.png","message":"System is in maintenance mode.","userAgent":"Mozilla/5.0 (Windows) mirall/3.4.4stable-Win64 (build 20220318) (Nextcloud, windows-10.0.18362 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"23.0.3.2","exception":{"Exception":"Sabre\\DAV\\Exception\\ServiceUnavailable","Message":"System is in maintenance mode.","Code":0,"Trace":[{"file":"/snap/nextcloud/30258/htdocs/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"checkMaintenanceMode","class":"OCA\\DAV\\Connector\\Sabre\\MaintenancePlugin","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/3rdparty/sabre/dav/lib/DAV/Server.php","line":456,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/apps/dav/lib/Server.php","line":339,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/snap/nextcloud/30258/htdocs/remote.php","line":166,"args":["/snap/nextcloud/30258/htdocs/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/snap/nextcloud/30258/htdocs/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php","Line":85,"CustomMessage":"--"}}

Sorry, I cannot help you either, but for the admins: I have the same problem :pensive:
No longer accessible after Backup Cloud: writing to the ā€œappsā€ directory is not possible - :information_source: Support - Nextcloud community

Have you checked to see whether or not your config.php was reset/blank/corrupted?

In my specific case, I ran out of storage and it broke NextCloud. Did you have a space issue as well?

edit
Just checked your thread. Yeah you had a space issue. Did you have the backup app installed from within NextCloud? Or were you using something else that may have filled up the space?

Yes, I ran out of space too. Sorry, I am a noob, where can I finde the config.php? I use a snap version as you.

Edit: Yes, I installed the backup-app within nexcloud. Surely nothing else used the space.

My config.php looks like yours.

Donā€™t worry about it. Fellow noob here.

Seems like the backup app is not the best solution for my use case. The intention was to have the local backups done and then export to cloud using the built in features. Will have to try and get rClone working for that purpose in future. If thereā€™s no replies Iā€™ll just go ahead with scrubbing and starting over. Itā€™ll take time to get the backups done again, but at least it will be more stable without the backup.

Iā€™m hoping that thereā€™s a way to recover the config file though. Let me check if I had a backup somewhereā€¦

edit
Well. No backup of the config. Bummer. On another note @Hasso - I see in your thread that you were doing the backup. Did you also intend to have it move to cloud storage after?

And to answer the question in your thread - if youā€™re using Windows then WinSCP is best to copy the files directly from the Linux box. Other than that - I have Webmin installed on my box which I can use to directly view/edit the files. Also makes it easier to copy/paste the information.

Well, I think it is working again. I found a config.php of an old snap installation. Look at this link, maybe it will work for you, too:
Cannot write into ā€œappsā€ directory Ā· Issue #1492 Ā· nextcloud-snap/nextcloud-snap Ā· GitHub

No, the backup should have been local.

1 Like

Some progress. Different error now though.

Cannot create "data" directory

This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/23/go.php?to=admin-dir_permissions

Will look into it some more.

Been playing with rClone to try and get it working in the mean time. While Iā€™m hopeful that the current config can be retrieved, Iā€™m preparing to move forward if it canā€™t be done.

So let me go through some of what was done so far. In case someone comes across the same problem.

FYI - to make things easier from a GUI perspective, I did the work using Webmin. If you donā€™t have it installed then you can do so after deleting some files/directories from the following path.

/var/snap/nextcloud/common/nextcloud/data/

Once youā€™ve done so you can install Webmin and use it to delete everything else from that path. What I did was leave the last dated directory intact along with the only file that was there (canā€™t remember the name).

If you manage to rebuild your config - GREAT! Immediately log in and disable the backup app. If not and you move forward with a reinstall of NextCloud - just ensure that you donā€™t add the backup app.

Now this is as far as Iā€™ve gotten. Download rClone based on your distro.

Allow the port through the firewall.

ufw allow 5572

Create the directory that youā€™ll house the password file.

mkdir /home/nextcloud/

Change to that directory then create a password file.

htpasswd -c pwdfile username

That should create the file and then prompt for the password which will be encrypted. Next you can run rClone GUI and do your initial setup there.

rclone rcd --rc-web-gui --rc-htpasswd /home/nextcloud/pwdfile --rc-addr 192.168.0.2:5572

Replace the 192.168.0.2 with the actual IP for your box. You should then be able to access the GUI from there.

rClone itself seems pretty straightforward. The next step is to figure how to create a CRON job to run at specific times, and see whether or not rClone will do incremental updates.

The intention isā€¦letā€™s say a backup has reached 30% - 5 files have changed. Iā€™d want it to continue from the 30% and do the changed files first if possible. Added to that - Iā€™d only want it to run like 10PM-6AM when there is less usage on the network. Iā€™d want it to not upload anything outside of those hours to minimize interrupting general usage.

/var/snap/nextcloud/common/nextcloud/data/

That seems to be the path that houses all of the uploaded user data in separate directories according to the usernames. Iā€™d just upload and encrypt that with rClone.


Thatā€™s where I am at the moment. Iā€™m hopeful that the information will help others that pass by and see it with similar problems. @Hasso - Iā€™m glad you got yours back up and working. Iā€™ll keep at mine, but Iā€™m hopeful someone will see this and be able to help get things back on track.

Maybe itā€™s possible to remove the current SNAP without removing the user data? I dunno. May not be able to continue sync from where it is since it would be a different install. But - hopeful.

Currently looking through this thread externally.

Want to see if itā€™s possible to get the kind of backups I specified before. Going to use that link as a template to set up once I get the box issue resolved.

If thereā€™s no way to get things sorted by later - Iā€™ll have to just scrub the box and start over.

Morning all. Something I noticed on the older drive while going through to look for stuff. In this path:

/var/snap/nextcloud/current/nextcloud/config/

There is a file called config.php.save which seems to be a backup of the original config file. Unfortunately, on the current install there is no such file in the path. Is it at all possible for me to use the old file to recover the current install?

Well. Good news. managed to get back to the login page. But now Iā€™m getting another error. Let me paste the config.php file and see if thereā€™s anything that anyone can see - maybe something to be fixed?

<?php
$CONFIG = array (
  'instanceid' => 'abcdefg',
  'version' => '23.0.3.2',
  'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
  'dbtype' => 'mysql',
  'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
  'dbport' => '',
  'dbname' => 'nextcloud',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'abcdefg',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'installed' => true,
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/snap/nextcloud/current/htdocs/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps',
      'url' => '/extra-apps',
      'writable' => true,
    ),
  ),
  'supportedDatabases' => 
  array (
    0 => 'mysql',
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/tmp/sockets/redis.sock',
    'port' => 0,  
  ),
  'loglevel' => 2,
  'maintenance' => false,
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'xxx.xxx.xxx.xxx',    
  ),
);

Iā€™m getting this when I try to log in.

The server was unable to complete your request.

If this happens again, please send the technical details below to the server administrator.

More details can be found in the server log.

Technical details
Remote Address: xxx.xxx.xxx.xxx
Request ID: 0atx0Ocd70HAzk9VhvSJ

Thanks in advance. And thanks to @Hasso for pointing me to that other thread. Good stuff.

edit
Also unable to add/modify users from the CLI. Getting this.

[admin@ncbox data]# sudo snap run nextcloud.occ user:add --display-name="newadmin" newadmin
Enter password: 
            
  Aborted.  
            

user:add [--password-from-env] [--display-name [DISPLAY-NAME]] [-g|--group [GROUP]] [--] <uid>

Itā€™s basically aborting right as itā€™s run. But at least it shows the login page now. No existing user can log in though. Any ideas?

edit
So that problem seems to have been due to me being lazy. Was using Webminā€™s terminal to get it done and it was giving that error. I can use Putty to get it done and add/modify users, but even so I still get the error. Is there a way I can find/open the log and find the request ID to get more details?

Scrubbed the box and restarted from scratch. Will ensure that a backup of the config file is taken periodically. Many thanks for your time and patience. If someone else comes across this I hope one of the previous things can help. Either the script to rebuild the config, or being lucky enough to find a backup config.

Marking this last post as the solution. Kudos to @Hasso. Keep up the good work @(the NextCloud Team).

Links to the specific posts (above) can be found below.