[WIP] Fix database:dump:remote.

Escape application name and tidy up database dump functionality.

Bug fix: yes
Feature addition: yes
Backwards compatibility break: not yet
Tests: not run
Fixes the following tickets: #345

Todo:

- [x] Finish refactor of symfony2 db methods.
- [ ] Finish refactor of symfony1 db methods.
- [ ] Possibly solve #146 here too.