# Add option to disable backup compression

**URL:** https://meta.discourse.org/t/add-option-to-disable-backup-compression/37288
**Category:** Feature
**Created:** [30.Декабрь.2015 22:43:36 UTC](https://meta.discourse.org/t/add-option-to-disable-backup-compression/37288 "2015-12-30T22:43:36Z")
**Posts on this page:** 1
**Showing post:** 19

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [13.Январь.2016 08:42:46 UTC](https://meta.discourse.org/t/add-option-to-disable-backup-compression/37288/19 "2016-01-13T08:42:46Z")

</div>

Ruby is not my forte (i.e. I don’t write Ruby) - but here was my secondary thoughts when I saw `pax` wasn’t installed as default in Ubuntu:

```Ruby
metadata_params = "--transform='s,#{Regexp.escape(@meta_filename).shellescape},#{Regexp.escape(File.basename(@meta_filename)).shellescape},g' #{@meta_filename.shellescape}"
dump_params = "--transform='s,#{Regexp.escape(@dump_filename).shellescape},#{Regexp.escape(File.basename(@dump_filename)).shellescape},g' #{@dump_filename.shellescape}"
uploads_params = ""
if @with_uploads
        upload_directory = "uploads/" + @current_db
	upload_full_path = File.join(Rails.root, "public/" + upload_directory)
	uploads_params = "--transform='s,#{Regexp.escape(upload_full_path).shellescape},#{Regexp.escape(File.basename(@upload_directory)).shellescape},g' #{@upload_full_path.shellescape}"
end
shell_cmd = "tar --create --dereference #{metadata_params} #{dump_params} #{uploads_params} --verbose --show-transformed-names"

# execute our command or log it something.
`#{shell_cmd} | gzip -5 > #{tar_filename}.gz`

```

###Notes

- Full pathnames are used on purpose to avoid any possible collisions
- The only other thing I would consider replacing / escaping is the use of “commas” (`,`) in the regular expression - other wise file or path names with a comma included might be of issue.
- could probably do with an anchor at the beginning of the regular expressions.
- `--verbose --show-transformed-names` is there to help debug the replacements.

Yes it can be done cleaner - but this hopefully get’s it working…  
… again I haven’t tried this in dev.

By the way - Ruby’s `Regexp.escape` seems poor - it should take a 2nd parameter for the delimiter.

---

_[View the full topic](https://meta.discourse.org/t/add-option-to-disable-backup-compression/37288)._
