I have a few Questions regarding the above topics . I currently have Decembers 2017 Nextcloudpi image running on a raspberry pi and I’ve formatted my HDD to BTRFS.
1)I’ve backed up database and installation with the backup option in Nextcloud-config and exported my configuration to a file, I’ve then taken a snapshot of my data directory. My questions is if i moved my Nextcloud to another device, for example an odroid or say my HDD died and I needed to transfer to an new one, how would I restore my data using the Snapshot or is this simply meant as a way to revert to a previous snapshot should anything go wrong with an update?
I’m interested in De -googling my life, however I currently use Google music I would like to be able to use Ampache (or alternative) to stream music to my phone/devices when away from home but have the server running alongside Nextcloud . Is it possible to have Nextcloud store my music and then use the database with Ampache ? or is this not how it works ? can I run both servers on the same device ?
I understand that I would need a dynamic DNS to access Nextcloud away from my Network but would I be able to access Ampache the same way if its on the same device?
thank you in advance for your help
I have no experience with BTRFS and can therefore not help you with point 1) (however I think snapshot in BTRFS implies, that the current state of the files is captured, no actual copying is done. So if your HDD dies, the data is gone)
Yes, this can be done, but you need to make sure that both nextcloud and ampache have the permission to access/read your music directory.
I thinkt the recommended solution is, to use different virtual hosts for different subdomains of your DNS domain. e.g. ampache.yourdomain.tld for Ampache and nextcloud.yourdomain.tld for Nextcloud. However I think your dynamic DNS provider needs to redirect the subdomains. You can then just create virtual host for each service in your apache config files.
Thanks for the help, do you use the backup feature from nextcloud-config for datadir backup as well? Yeah I thought as much regarding snapshots nice as an addition but not a failsafe.
I thought I would have to allow access by both is this the best way to do it or is it best to let ampache control and store the database itself?
Wow this sounds a little complex. I’ve never set up a DDNS before,but as I understand it, if I had 2 different devices each assigned a different local IP, the router would direct the packets from each domain name to the server assosiated by it local IP. But on the same device with the same local IP. I’m not sure I understand how it works does Apache then assign a local host IP to each server I.e 127.0.0.1 and 127.0.0.2 and Apache does the filtering to each server?
Sorry for the noob question
No, I actually use incremental backup of the data-directory using rsync. Which is basically what is described in the Nextcloud backup docs but only syncs the changed files. So you have a full copy of your data in a series of snapshots. I run the following cron script daily:
#Nextcloud Folder Backup Script
# is preformed daily
#Todays date in ISO-8601 format:
#Yesterdays date in ISO-8601 format:
DAY1=`date -I -d "1 day ago"`
#The nextcloud directory:
#The target directory:
#The link destination directory:
#The rsync options:
OPT="-Aah --delete --link-dest=$LNK"
#Execute the backup
sudo rsync $OPT $SRC $TRG
plus also a mysql database backup:
mysqldump --single-transaction -h localhost -u YOURNEXTCLOUDDATABASE -pYOURPASSWORD nextcloud > /BACKUPDIRECTORY/nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
Make sure to also backup your data-directory in a similar script (just change the directories accordingly)
Ampache anyway has its own database to store information on your music files. However you can give it access to a folder in your nextcloud data directory to look for music files. It will then scan this folder for music, add them to its own database and serve those over the ampache interface/API. However I do not use this.
I use a local folder e.g.
~/Music to manage all my music manually. I then add this to both Ampache and Nextcloud (as external storage). However that way you cannot upload music directly from Nextcloud (or I have not figured out how yet).
Only at first
This is what you would need to do:
register at a ddns service (e.g. https://www.twodns.de/ allows any number of subdomains)
rederict the two HTTP ports (80/443) to your pi’s local ip at your router (depends on your model)
Configure a virtual host in Apache (one for Nextcloud and one for Ampache) and obtain a certificate for it via Let’s Encrypt (a fairly detailed tutorial can be found here virtual hosts are described under Step 4, securing your connection under Secure it with HTTPS)
Have fun exploring and learning about hosting your own services!
@darioce you Sir are a gentleman and a scholar, this has answered all my questions .
Thankyou so much for your help.
There is also an app called Music that has integrated Ampache support (so any Ampache client like Powerampache or Tomahawk can be used):
If you use that you wouldn’t need an additional Ampache server.
@alfred this looks pretty good and would certainly make it easier. Out of interest would you happen to know how stable this app is? I did notice on the Readme it suggests the Ampache server attached is experimental.
Also how would I get this to work with DDNS? does it just use the one domain assigned to Nextcloud and the powerampache client would work through Nextclouds Domain Name ? its mainly so I can use it away from my local network being able to access Nextcloud through the Nextcloud client app and music through the powerampache app.
To question 1) btrfs is a cow file system (good explanation on Wikipedia) which makes it really easy to do performance incemental backups. The creation of the snapshots it self doesn’t talk any notable time and give a backup against some kinds of human mistakes. Deleting a file in nextcloud or overwriting it. With btrbk you can automatically sent the snapshots to a different btrfs volume on a second harddrive and have a backup against a failing drive.
Do to the cow filesystem it is really performend the incremental backup on my 4tb volume normally only takes a few minutes, of course depending on how much chained since the last backup.
with btrfs snapshots your data will be gone if your USB drive is gone. The missing piece of the puzzle for BTRFS in NCP is an upcoming feature to be able to efficiently transfer the incremental snapshot over SSH to another machine, or to another local drive.
when this is in place, the best setup will be to
- run periodic nc-backup without data, to save accounts, database, contacts and such
- run periodic nc-snapshots and sync them with another hard drive or remote machine through SSH to save your data.
NCP comes with several DDNS providers, so you don’t have to understand too much, just pick one and get a domain on their website (see NCP documentation for details)
Also you can check in the wiki for other combinations, such as having 2 USB drives, and backing up the data dir to the second one, in case your main one fails.
I hope that helps
This does help alot thanks @nachoparker but how would I restore my data from the snapshots . I understand how to use NC- restore to restore the database …etc .
at this point the snapshot is just like any other directory, so you would have to
- replace the datadir with the snapshot dir
nc-scan in order to make NC aware of the file changes
we might make this more simple in the future
Thanks for the explanation I understand how it works now I didn’t realise it was as simple as it being another directory.
Cant wait for the upcoming features.
Keep up the good work @nachoparker
@Greylinux It works pretty well actually even thought it is considered experimental. Some clients like Tomahawk and Powerampache are quite stable to use.
You don’t need an additional domain name because it is just an app for Nextcloud so you use it like that:
It is pretty well documented here:
Sorry for the delay I only received my Odroid HC1 2 days ago and have now completed the setup. I’m trialling the music app with power ampache, so far it’s brilliant absolutely no problems.
Thanks for your help @alfred. On the Odroid the streaming is flawless can’t believe how quick it is
I’ve got everything running well with the music server and I can play music in the Power Ampache app. However I can’t create any local playlists on the app, also when I open the app and I try to make a playlist it gives me a warning.
action not supported
Is this normal at the moment as I know the music app on Nextcloud is still relatively new and this could be whats causing the issue ?