IRC logs for #farmOS, 2021-05-17 (GMT)

2021-05-16
2021-05-18
TimeNickMessage
[22:34:27]* kta[m] has joined #farmos
[12:19:42]* wgardiner[m] has joined #farmos
[12:36:00]<ssoyrnoz[m]>I have been using farmOS for a couple months now on a virtual machine and I have a database loaded with all my livestock info. I just got an always-on comp set up that I want to move my farmOS stuff to. I'm using Docker to contain the farmOS on the VM, is there an easy way to pack up the docker, and drop it on the new machine with all my database additions intact? Thank you.
[12:39:37]<mstenta[m]>Hi ssoyrnoz - Yes! You basically just need to take a database dump from the old one and import it into the new one.
[12:39:46]<mstenta[m]>Have you uploaded any files? (Photos etc?)
[12:40:01]<ssoyrnoz[m]>I think one pic just to test it out.
[12:40:21]<mstenta[m]>OK, well if you're OK losing that, it will make things easier.
[12:41:46]<ssoyrnoz[m]>Yeah, I don't have any files in the DB that can't be replaced easily.
[12:42:56]<ssoyrnoz[m]>I do have a couple customizations to farmOS via the drupal admin page and also user made modules. Again, nothing I can't replicate but would be nice if I could move them over too, but not necessary
[12:43:04]<mstenta[m]>Well just to be safe, can you find the asset/log that you uploaded that test file to, edit it, and delete the file from it? That will ensure that there are no missing files referenced later on (which might interrupt your eventual migration to farmOS 2.x)
[12:43:25]<ssoyrnoz[m]>Yea, that is easy enough
[12:43:28]<mstenta[m]>If you've made changes through the UI, those will be stored in the database, so they will come over with the database basckup
[12:43:42]<ssoyrnoz[m]>Nice
[12:43:46]<mstenta[m]>If you've made changes to code, you will need to move/replicate those separately
[12:44:14]<mstenta[m]>Are you familiar with how to dump and import a MariaDB/MySQL database?
[12:44:40]<ssoyrnoz[m]>Nothing code based yet, I wish I had more time to do a few changes but alas life gets in the way. I can't say I am familiar with that process.
[12:46:46]<mstenta[m]>Ok, I might not be able to walk you through it myself today... but basically you need to run `mysqldump [options] > database.sql` on the old server, then move that `database.sql` to the new server and run `mysql [options] < database.sql`
[12:47:11]<mstenta[m]>There are other ways to do it, like with PHPMyAdmin
[12:47:16]<mstenta[m]>But that's the basic idea
[12:47:34]<mstenta[m]>Before you do that, you should install farmOS on the new server
[12:47:57]<ssoyrnoz[m]>I'm assuming those are linux terminal commands, and the [options] part I can google easily enough?
[12:47:57]<mstenta[m]>and then you'll just drop that new database entirely, recreate it as a blank db, then import
[12:48:12]<mstenta[m]>that will ensure that your new server's `settings.php` is set up and has the new database credentials
[12:48:22]<mstenta[m]>Yep!
[12:48:29]<mstenta[m]>are you running mysql/mariadb in docker too?
[12:48:55]<ssoyrnoz[m]>K, I'll give it a shot. Can I use the same dump command as a method to backup/archive my DB?
[12:49:23]<ssoyrnoz[m]>I'm using basically the docker container you provided instructions on how to install and build.
[12:49:30]<ssoyrnoz[m]>farmOS 1.7x?
[12:51:31]<mstenta[m]>Yep! Same dump command works for backups
[12:51:50]<mstenta[m]>Ok, this one? https://github.com/farmOS/farmOS/blob/7.x-1.x/docker/docker-compose.deve...
[12:53:15]<mstenta[m]>If that's the one you're using, then you'll also want to run `[myfarmOS-url]/update.php` after you import the database dump - because there's a good chance that you'll be updating to a newer version at the same time
[12:53:26]<mstenta[m]>(that development docker image is not pinned to a specific version, FYI)
[12:53:42]<ssoyrnoz[m]>Yeah, I am behind a bit on my farmOS version. I used the instructions found at https://farmos.org/hosting/docker/
[12:54:21]<mstenta[m]>Oh OK... can you copy and paste your `docker-compose.yml` file? that will tell me all i need to know
[12:54:28]<ssoyrnoz[m]>Sure, sec
[12:54:59]<ssoyrnoz[m]>ACTION < https://matrix.org/_matrix/media/r0/download/matrix.org/TKORspdCPoZgGUkQ... >
[12:55:48]<mstenta[m]>ok cool thanks
[12:56:03]<mstenta[m]>can you run `sudo docker ps`?
[12:57:23]<ssoyrnoz[m]>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[12:57:23]<ssoyrnoz[m]>0ee27ccae187 farmos/farmos:dev "docker-entrypoint.sā€¦" 5 weeks ago Up 4 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp farmos_www_1
[12:57:23]<ssoyrnoz[m]>bd9e9bdcc9c8 mariadb:latest "docker-entrypoint.sā€¦" 5 weeks ago Up 4 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp farmos_db_1
[12:57:28]<ssoyrnoz[m]>Bit messy, sorry
[12:57:38]<mstenta[m]>perfect! thanks!
[12:57:39]<mstenta[m]>one sec...
[12:57:57]<mstenta[m]>`sudo docker exec farmos_db_1 mysqldump -u farm --password=farm farm > database.sql`
[12:58:01]<mstenta[m]>try running that...
[12:58:17]<mstenta[m]>that *should* dump your database to a file called `database.sql`
[13:00:02]<ssoyrnoz[m]>File created, size is 10M, sounds like there's something in there
[13:00:58]<mstenta[m]>then, on your new server, after you install farmOS from scratch, you'll need to run:
[13:00:58]<mstenta[m]>`sudo docker exec farmos_db_1 mysql -u farm --password=farm farm -e "drop database farm; create database farm;"`
[13:01:14]<mstenta[m]>that will drop the new database and recreate it (leaving you will a completely blank `farm` database)
[13:01:25]<mstenta[m]>DO NOT run that on the old server
[13:01:26]<mstenta[m]>:-)
[13:01:38]<ssoyrnoz[m]>Heh, thanks.
[13:01:41]<mstenta[m]>then, move the `database.sql` file to the new server and run:
[13:02:49]<mstenta[m]>`cat database.sql | sudo docker exec -i farmos_db_1 mysql -u farm --password=farm farm`
[13:02:59]<mstenta[m]>that should import the databsae
[13:03:17]<mstenta[m]>then go to `[myfarmOS-url]/update.php` in your browser and click through the steps
[13:03:23]<mstenta[m]>then you should be all set!
[13:04:05]<ssoyrnoz[m]>Awesome, thank you very much for all your help
[13:04:35]<mstenta[m]>sure thing - no guarantees everything will work - but that's the basic idea ;-)
[13:05:10]<mstenta[m]>come to think of it, you may need to use `-u root` instead of `-u farm`... but give it a try first
[13:05:12]<ssoyrnoz[m]>Heh, yeah
[13:05:19]<ssoyrnoz[m]>Ok
[13:06:08]<mstenta[m]>and just to be clear: you shouldn't be exposing these development containers to the public...
[13:06:18]<mstenta[m]>because the root password is known to all :-)
[13:07:14]<mstenta[m]>you can change that in your `docker-compose.yml` file - and stop exposing port 3306 entirely if you do plan to make your farmOS available on a public network
[13:07:39]<mstenta[m]>(this is why these are considered "for development only") ;-)
[13:09:05]<ssoyrnoz[m]>For now I plan on running it over the LAN, which is behind at least two firewalls. I might put this on a public facing page one day, but no time soon.
[13:09:32]<ssoyrnoz[m]>I'm no web developer so security in this context is not something I know how to handle other than throwing it behind firewalls and keeping it local only if possible.
[13:10:32]<mstenta[m]>cool cool that'll work! i would feel irresponsible if i didn't at least say it :-)
[13:16:00]<ssoyrnoz[m]>I understand, it's like using password for a password.
[13:22:14]<ssoyrnoz[m]>Thank you for all your help :)
[16:34:03]<shane_aldrich[m]>mstenta: I think I've finally got everything set up properly with GitHub, the fork, the local repository, etc. How do you recommend I approach adding in my Fungi module while working along this path? Should I place it in `/farm/modules/assets`, or create a new folder somewhere else? No rush.
[16:37:12]<symbioquine[m]><mstenta[m] "`cat database.sql | sudo docker "> MariaDB has a feature for loading data on first-startup...
[16:38:39]<symbioquine[m]>See "Initializing a fresh instance" at https://hub.docker.com/_/mariadb
[16:40:00]<symbioquine[m]>TL;DR; Add a new volume mount `- './db-init:/docker-entrypoint-initdb.d'` and put your `database.sql` file in `./db-init/`
[16:41:32]<symbioquine[m]>See https://farmos.discourse.group/t/symbioquines-2-x-migration-testing-log/... for an example of how I use it for my development testing.
[16:46:41]<mstenta[m]>shane_aldrich put your module in `sites/all/modules`
[16:47:06]<mstenta[m]>And whenever you need to update your version of farmOS you'll just preserve that sites folder
[16:49:04]<shane_aldrich[m]>That's how I was doing it before. Since I have a complete fork of farmOS 2.x, I just wanted to double-check. I did get the Material asset module created in my local repository and pushed it to my instance of farmOS under the shane_farmOS branch. Thanks!
[16:49:17]<mstenta[m]>Cool!
[16:49:37]<shane_aldrich[m]> * That's how I was doing it before. Since I have a complete fork of `farmOS 2.x`, I just wanted to double-check. I did get the Material asset module created in my local repository and pushed it to my instance of farmOS under the `shane_farmOS` branch. Thanks!
[16:49:48]<mstenta[m]>Yea bottom line is you just want to keep your custom module code separate from the farmOS code in profiles/farm
[16:50:17]<mstenta[m]>(with the exception of the material asset, which is intended to be part of core pull request)
[16:51:25]<shane_aldrich[m]>Sweet! All I did was copy Compost and replace all instances of compost/Compost with material/Material. Nothing more than that yet.
[16:54:13]<shane_aldrich[m]>Another question... I see that others are using MariaDB, is that only used outside of Docker?
[16:54:19]<mstenta[m]>Cool! That might be all you need!
[16:54:28]<mstenta[m]>Have you tried installing and testing it out?
[16:54:42]<mstenta[m]>(sorry for quick replies... Chasing kids around here)
[16:55:22]<shane_aldrich[m]><mstenta[m] "Have you tried installing and te"> Just installing farmOS again now. That's what inspired the question.
[16:58:00]<mstenta[m]>šŸ™Œ
[17:22:56]<shane_aldrich[m]>Installed again. However, having the Material module in `/farm/modules/asset/material` doesn't show up anywhere on the site. Just the taxonomy.
[17:23:54]<mstenta[m]>did you rename the files too? or just replacements in the files?
[17:24:23]<mstenta[m]>eg `farm_compost.info.yml` -> `farm_material.info.yml`
[17:25:54]<shane_aldrich[m]>All of the files were renamed as well.
[17:27:16]<shane_aldrich[m]>Also, it did not show up on the list of modules at the beginning of the installation process. Not sure if that's hard-coded into the install procedure or not.
[17:28:00]<mstenta[m]>oh yea that's hard coded
[17:28:11]<mstenta[m]>(good point we'll need to add it there as well)
[17:28:14]<mstenta[m]>but it should show in /admin/modules
[17:28:17]<mstenta[m]>(after install)
[17:28:55]<shane_aldrich[m]>I just checked it again, and it still isn't showing up. Is there a way to re-scan the directory for updates?
[17:29:17]<mstenta[m]>yea maybe need to clear cache...
[17:29:35]<mstenta[m]> /admin/config/development/performance
[17:29:41]<mstenta[m]>(although i don't think you need to)
[17:31:27]<shane_aldrich[m]>No luck with the admin panel or `drush cr`
[17:38:22]<mstenta[m]>Womp. Gonna need to see the code I guess
[17:39:59]<shane_aldrich[m]>https://github.com/s33a/farmOS/tree/shane_farmOS/modules/asset/material
[17:41:15]<mstenta[m]>that all looks perfect to me (well done!)
[17:41:27]<mstenta[m]>strange that it isn't showing up
[17:41:52]<mstenta[m]>100% sure that your branch is checked out? maybe it got revered to 2.x branch somehow?
[17:42:00]<shane_aldrich[m]>Aww, shucks! That was super easy!
[17:42:54]<shane_aldrich[m]>ACTION uploaded an image: (11KiB) < https://matrix.org/_matrix/media/r0/download/matrix.org/SvXyXYNDtjCvHsTm... >
[17:46:58]<shane_aldrich[m]>What if I switch from Docker moving forward? It was easy to set up, but now I'm thinking about building my stack in WSL2/Ubuntu. If I was to go that route, what would be the preferred stack with versions?
[17:49:11]<mstenta[m]>sorry gotta run - time for dinner
[17:49:43]<shane_aldrich[m]>No worries! Fill that belly! šŸ”
[17:49:57]<mstenta[m]>i might try to join the dev call on thursday - maybe we can take a look then!
[17:50:08]<mstenta[m]>if you don't figure it out before!
[17:50:37]<shane_aldrich[m]>Yeah, I'll be on the call. But I hope to have it fixed first.
[17:50:37]<mstenta[m]>i think i'll need to see your screen to debug better
[17:50:47]<mstenta[m]>cool! good luck! if i have any ideas i'll ping you here
[17:51:24]<mstenta[m]>oh what happens if you do `drush en farm_material`?
[17:56:08]<shane_aldrich[m]>That says "already enabled", but doesn't show up in the interface. Hmmm
[17:56:34]<mstenta[m]>oh DOH! i forgot... oh this is embarassing...
[17:56:44]<mstenta[m]>we already have a module called `farm_material` lol
[17:56:53]<mstenta[m]>(for the taxonomy)
[17:57:22]<shane_aldrich[m]>Doh! šŸ˜‚
[17:57:38]<mstenta[m]>so we'll need to figure out how best to merge them - but for now just try renaming `farm_material.info.yml` to `farm_material_asset.info.yml`
[17:57:44]<mstenta[m]>then `drush en farm_material_asset`
[18:01:05]<shane_aldrich[m]>Doesn't work that way due to both PHP files being named the same "Material.php". I'll change the name of the new file to "MaterialAsset.php" and see what happens.
[18:01:39]<mstenta[m]>oh you have to update the `namespace`
[18:01:44]<mstenta[m]>but the class name and file name won't matter
[18:03:57]<shane_aldrich[m]>`namespace` and `class` had to be updated
[18:06:26]<shane_aldrich[m]>It shows up now. But trying to add a `Material Asset` results in "Page Not Found"
[18:10:51]<mstenta[m]>Try drush cr
[18:10:51]<mstenta[m]>(really shouldn't need to change class name)
[18:10:58]<mstenta[m]>(that's what the namespace is for)
[18:11:47]<shane_aldrich[m]>I did that and got an error. I'm about to start from scratch again. Only after I see if I can move away from Docker with a stack using this:
[18:11:47]<shane_aldrich[m]>https://www.drupal.org/docs/develop/local-server-setup/linux-development...
[18:12:13]<shane_aldrich[m]>My inner geek is coming out strong! šŸ¤£
[19:06:30]<mstenta[m]>scratch the itch! :-)
[19:07:41]<shane_aldrich[m]>šŸ•ļø Listening in on a Mycology Clubhouse chat while I configure my new stack from scratch šŸ˜‰