Files in shared/uploads directory not being uploaded on deploy

hi there,
the files in my shared/uploads directory are not being uploaded to my production server when I deploy and I’m not sure why.

I moved my assets / files from app/uploads into the shared directory like so:

└── uploads/
└── 2015/
└── 03/
- picture.jpg
- picture2.jpg

Now, I know (what I’m about to share) is backwards and not the correct way to get the files in the uploads directory to the production server but it worked. However, I know there must be a better way. So, I was able to get the files uploaded to the server by moving them into web/app/plugins/uploads directory, updated my .gitignore and then checked them all into my git repository before I ran $ bundle exec cap production deploy

Then after they were uploaded to web/app/plugins, I moved them into my /srv/www/ directory and then chomd 755 on the /srv/www/

Also, I made sure the following was in my deploy.rb file

set :linked_dirs, fetch(:linked_dirs, []).push('web/app/uploads')

I know there must be a better way to get your uploads to the production server than the way I did? If someone would please share how to do so…I’d be VERY MUCH GRATEFUL.

Also, it should be noted that I ran the $ bundle exec cap production deploy command from my development environment and skipped deploying to a staging server…if it makes a difference?

Thanks in advance!

You should never be committing files into uploads/. There’s a reason it’s called “uploads” :smile:

Either they’re assets or uploads. If they’re assets, then commit them. If you do need to upload “uploads” to your server, just rsync/scp them outside of a deploy.

I guess on this topic…how do I prevent the uploads currently on the destination server from being lost when I do an bedrock-ansible deploy? The deploy of files works great but it wipes out all my uploads. I wouldn’t want to rsync after going live as the production database and uploads would be more current than my local.


They should be preserved.


Uploads are kept in shared/uploads and symlinked on every deploy.

Hmmm. That doesn’t seem to be happening. I’m running ./ staging from the ansible directory. It definitely empties out that directory each time I deploy.

Steps I took:

  1. Provisioned the server (Digital Ocean Droplet) for the first time a few minutes ago.
  2. Imported by database
  3. Ran the deploy about 5 times and each time my uploads were emptied


@jasonhjohnson it would be useful if you would provide some debugging information such as:

  1. your deploy log
  2. output of paths/directories on your server (such as shared/uploads and release uploads directories).

Not sure how you expect us to provide help without any information.

I didn’t mean to withhold detail from you. Perhaps it could have been a “just make sure you change this one value”-type of resolution.

Deploy log:

./ staging

PLAY [Deploy WP site] *********************************************************

GATHERING FACTS *************************************************************** 
ok: []

TASK: [deploy | Initialize] *************************************************** 
ok: []

TASK: [deploy | Clone project files] ****************************************** 
changed: []

TASK: [deploy | write unfinished file] **************************************** 
changed: []

TASK: [deploy | Copy files to new build dir] ********************************** 
changed: []

TASK: [deploy | Move project subtree into root folder] ************************ 
skipping: []

TASK: [deploy | Remove unwanted files/folders from new release] *************** 
changed: [] => (item=.git)

TASK: [deploy | Run pre_build_commands_local on Ansible host] ***************** 
changed: [ ->] => (item={'path': u'../site/web/app/themes/teamjb', 'cmd': 'npm install'})
changed: [ ->] => (item={'path': u'../site/web/app/themes/teamjb', 'cmd': 'bower install'})
changed: [ ->] => (item={'path': u'../site/web/app/themes/teamjb', 'cmd': 'gulp --production'})

TASK: [deploy | Copy project local files] ************************************* 
changed: [ ->] => (item={'dest': 'web/app/themes/teamjb', 'src': u'../site/web/app/themes/teamjb/dist', 'name': 'compiled theme assets'})

TASK: [deploy | Copy project templates] *************************************** 
changed: [] => (item={'dest': '.env', 'src': 'roles/deploy/templates/env.j2', 'name': '.env config'})

TASK: [deploy | Run pre_build_commands in the new_release_path] *************** 
skipping: []

TASK: [deploy | Check if project folders exist] ******************************* 
ok: [] => (item=vendor)

TASK: [deploy | Copy project folders] ***************************************** 
changed: [] => (item={'invocation': {'module_name': u'stat', 'module_args': u'path="/srv/www/"'}, 'item': 'vendor', u'stat': {u'uid': 1000, u'exists': True, u'woth': False, u'mtime': 1434371997.2436776, u'inode': 264686, u'isgid': False, u'size': 4096, u'wgrp': False, u'isuid': False, u'isreg': False, u'pw_name': u'web', u'gid': 33, u'ischr': False, u'wusr': True, u'xoth': True, u'rusr': True, u'nlink': 8, u'issock': False, u'rgrp': True, u'gr_name': u'www-data', u'path': u'/srv/www/', u'xusr': True, u'atime': 1434371997.2436776, u'isdir': True, u'ctime': 1434371997.2436776, u'isblk': False, u'xgrp': True, u'dev': 64769, u'roth': True, u'isfifo': False, u'mode': u'0755', u'islnk': False}, u'changed': False})

TASK: [deploy | Ensure shared sources are present] **************************** 
ok: [] => (item={'path': 'web/app/uploads', 'src': 'uploads'})

TASK: [deploy | Ensure shared paths are absent] ******************************* 
changed: [] => (item={'path': 'web/app/uploads', 'src': 'uploads'})

TASK: [deploy | Create shared symlinks] *************************************** 
changed: [] => (item={'path': 'web/app/uploads', 'src': 'uploads'})

TASK: [deploy | Run post_build_commands in the new_release_path] ************** 
changed: [] => (item={'cmd': 'composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts'})

TASK: [deploy | Finalize the deploy] ****************************************** 
changed: []

TASK: [deploy | Run post_finalize_commands] *********************************** 
changed: [] => (item=sudo service php5-fpm reload)

TASK: [deploy | debug ] ******************************************************* 
ok: [] => {
"msg": "master@c2abf93 deployed as release 20150615092055"

PLAY RECAP ******************************************************************** : ok=18 changed=13 unreachable=0 failed=0 

Additionally, /shared/uploads folder just has 2015->06 and then this directory is empty.


Have you actually uploaded the uploads directory? Perhaps this is not described well enough in the documentation, but since uploads are not handled on deployment, you have to get them on the server.


That was the problem, Kalen! I knew it was something simple and yes I completely missed that step if that was mentioned somewhere in the documentation. Seems like a step 3a could be added to the list of deployment steps here: mentioning this process. I’m sure you’re thinking I’m an idiot for even needing this step added, but, idiots abound.