Ghost / Ubuntu self hosted chmod ftp issues

I want to be able to access my content folder via ftp and have the ability to write into as well, but if I do that, then Ghost doesn’t like the permissions and vice versa.

Thoughts on how I can use ftp with the ghost directory?

I would ask - Why do you want to write into what is effectively an opaque Ghost storage area?

I can imagine that if you wanted to create your own image size processing you might want to… but that seems an unusual edge case.

If you are wanting to publish something via your blog website (e.g. custom CSS / JS files to be included using code-injection, an archive of public PDFs etc.), then document-root is usually somewhere like: system/nginx-root which is usually owned by your installation-user. You would have to tweak your nginx config to enable access to such files.

More for backing up and restoring.

For example… let’s say you move servers (as I am) from local to hosted… you’ll want to copy the image folder. Once you do, and put it where it belongs on the new server…the permissions are different. This could be ftp’d up there or scp’d up there.

When you go to run a command like ghostupdate you get the following error message:

One or more errors occurred.

One or more errors occurred.

1) Checking content folder ownership

Message: Your installation folder contains a directory or file with incorrect permissions:
- ./content/images.zip
Run sudo chown -R ghost:ghost ./content and try again.

If you run the command:

sudo chown -R ghost:ghost ./content

then it works fine.

However, you shouldn’t have to do that step each and every time.

Ah - for this I use sudo rsync - if you’ve kept your UIDs/GIDs in sync and include the permissions then the rsync will maintain ownership.

… as an example

/usr/bin/sudo /usr/bin/rsync -haviz --delete-delay \
  -e "/usr/bin/ssh -i /home/me/.ssh/id_rsa" \
  --rsync-path="/usr/bin/sudo /usr/bin/rsync" \
  /var/www/myblog/content/ \
  me@$target:/var/www/myblog/content/

Backing up content is only a partial backup - you should probably also include the file-system based config files, and more importantly, the database!

This question was asked a while ago: Best practice for backup database and all content

Doesn’t the JSON file from the labs export page include all the database info?

Also, feel free to dumb the rsync info down a bit. I’ve never used it before.

Thanks!

Think of rsync as just like scp - e.g. scp --options source target

/usr/bin/sudo /usr/bin/rsync  # local sudo super-powers to read all source files
  -h                          # human sizes in logging
  -a                          # archive - recursive with permissions
  -v                          # verbose
  -i                          # itemise updates
  -z                          # compress                   
  --delete-delay              # delete on target after all copying
  
  # use this SSH identity for the connection
  -e "/usr/bin/ssh -i /home/me/.ssh/id_rsa"                     
  
  # sudo super-powers on the target to set the permissions and ownership
  --rsync-path="/usr/bin/sudo /usr/bin/rsync"

  # always add the trailing / to prevent sub-folder oopsies.
  /var/www/source-folder/
  me@target:/var/www/source-folder/

I would guess that the json export does contain the blog data, though I have never tested that in earnest.

  • Are you using the ghost-cli to export daily into content/data/... ?
  • Do you just pipe in your email / password in a crontab?

I use a generic MySQL backup approach to backup all databases on the server, because I have to back up other non-Ghost databases anyway.

Oh - and all the backups have to run automatically, just before client-midnight.