66 Commits
Author SHA1 Message Date
Gerhard SchlagerandGitHub 464091fc90 FEATURE: Allow pausing of restore before DB migration and uploads are restored (#30269)
This can be helpful if you need to fix problems in the DB before the DB gets migrated as well as before uploads are restored.
2024-12-16 12:50:08 +01:00
Selase KrakaniandGitHub 944df9b036 FEATURE: Add --sql-only option to discourse backup (#30009)
This change allows backup CLI user to explicitly  exclude uploads from
the generated backup
2024-12-04 03:16:25 +00:00
Selase KrakaniandGitHub 6d46da23ed DEV: Support --skip-max-length-violations arg for remap (#29877)
Allow remap eligible rows to be skipped if new text exceeds column's max length constraint
2024-11-25 11:40:51 +00:00
Daniel WaterworthandGitHub 40b7247caa DEV: Add force option to discourse remap command (#27770) 2024-07-08 11:01:06 -05:00
Régis Hanol 527c176891 FEATURE: Add “s3_uploads” option to “discourse backup” script
Adds the “s3_uploads” option (default: false) to the discourse backup script, which temporarily forces the inclusion of S3 uploads in the backup.

Also removed all unnecessary “require” statements as loading Rails is sufficient.

The rest of the changes were made by the linter.
2024-05-29 19:22:33 +02:00
Leonardo MosqueraandGitHub abab41c6f6 FIX: discourse remap: fix output to avoid UX issue (#24905)
Before this commit, this output is possible:

```
Rewriting all occurrences of STRING1 to STRING2

THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES)
WILL RUN ON ALL 1 DBS
```

Which, when run from a script, might lead one to believe that YES was
automatically inserted into STDIN and the script is continuing.

Turns out this isn't the case so the obvious expectation is broken.

This commit swaps the order of those last lines to make it clear that
the script is blocked on input.
2023-12-14 16:30:14 -03:00
David TaylorandGitHub 21bbe0ad80 DEV: Be more lenient in CLI confirmation (#16290)
If someone types `yes` rather than `YES`, continue anyway.

The chance of typing `yes`, when you actually want to stop, is non-existent. The chance of typing `yes` when you meant `YES` is  high, and it's very frustrating when the script quite because you got the case wrong!
2022-03-25 20:14:41 +00:00
Jarek RadoszandGitHub 8013821e5b DEV: Correctly tag heredocs (#16061)
This allows text editors to use correct syntax coloring for the heredoc sections.

Heredoc tag names we use:

languages: SQL, JS, RUBY, LUA, HTML, CSS, SCSS, SH, HBS, XML, YAML/YML, MF, ICS
other: MD, TEXT/TXT, RAW, EMAIL
2022-02-28 20:50:55 +01:00
Jarek RadoszandGitHub 59c53ca6c0 DEV: Fix thor deprecation warning (#14680)
```
Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `DiscourseCLI`
```
2021-10-21 21:01:05 +02:00
Ikko AshimineandRobin Ward 0df07658c9 FIX: typo in discourse
occurences -> occurrences
2021-06-30 11:08:29 -04:00
Josh SorefandGitHub 1d3280690a DEV: Correct typos and spelling mistakes (#12812)
Over the years we accrued many spelling mistakes in the code base. 

This PR attempts to fix spelling mistakes and typos in all areas of the code that are extremely safe to change 

- comments
- test descriptions
- other low risk areas
2021-05-21 11:43:47 +10:00
David TaylorandGitHub b193108a77 DEV: Return a non-zero exit code when discourse remap is aborted (#12873)
This makes it much easier to integrate the script with external tools
2021-04-28 14:10:35 +01:00
Gerhard SchlagerandGitHub f5aa5fa623 FEATURE: Allow overriding the backup location when restoring via CLI (#12015)
You can use `discourse restore --location=local FILENAME` if you want to restore a backup that is stored locally even though the `backup_location` has the value `s3`.
2021-02-09 16:02:44 +01:00
Gerhard Schlager 69b068c274 REFACTOR: Restoring of backups and migration of uploads to S3 2020-01-14 11:41:35 +01:00
Krzysztof KotlarekandSam 3691eeeb52 FIX: Correct path to ImportExport module (#8227)
During the move from Classic autoloader to Zeitwerk import_export module was moved to correct file name convention.
https://github.com/discourse/discourse/commit/0db72e4291b5132748a92dcce916c264dbf1eb3a#diff-d896ec33b95afb7fae9f8bfe73d0580b

Problem is that export/import is still using old path to require that module

Meta: https://meta.discourse.org/t/topic-and-category-export-import/38930/40
2019-10-23 17:27:14 +11:00
Krzysztof KotlarekandSam 0db72e4291 DEV: Upgrading Discourse to Zeitwerk (#8098)
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. 

We no longer need to use Rails "require_dependency" anywhere and instead can just use standard 
Ruby patterns to require files.

This is a far reaching change and we expect some followups here.
2019-10-02 14:01:53 +10:00
Régis Hanol 556f1c6855 FIX: add back verbose option to DbHelper.remap 2019-07-31 17:30:08 +02:00
Régis Hanol 161733e965 DEV: remove duplicate Remap class and use DbHelper.remap instead
Follow-up to 48d4d2c11a
2019-07-29 18:43:40 +02:00
Sam SaffronandGuo Xiang Tan 5fbcc5cb35 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00
Gerhard Schlager 9329b2e782 FEATURE: Allow discourse script to skip disabling of emails after restore 2019-03-07 21:49:33 +01:00
Gerhard Schlager 6c3c99c2ff FIX: discourse script didn't allow backups with paths anymore
This restores the previous functionality. The script now allows the following options:

* `discourse backup` (uses the system generated filename)
* `discourse backup <some_filename>` (uses the provided filename)
* `discourse backup </some/path/to/filename>` (moves the backup to the provided path with the given filename)

Remote backup stores do not support the last option.
Some file extensions (like `.tar.gz`) are automatically removed from the provided filename.
2018-10-17 18:33:44 +02:00
Guo Xiang Tan 2aee54222d FEATURE: Support backup uploads/downloads directly to/from S3.
This reverts commit 0d69190cdc.
2018-10-15 09:43:31 +08:00
Guo Xiang Tan 0d69190cdc Revert "FEATURE: Support backup uploads/downloads directly to/from S3."
This reverts commit 57119a88cc.

We're doing a beta bump soon so un-revert this after that is done.
2018-10-11 11:08:23 +08:00
Gerhard SchlagerandGuo Xiang Tan 57119a88cc FEATURE: Support backup uploads/downloads directly to/from S3. 2018-10-11 10:38:43 +08:00
Guo Xiang Tan 6c5755c4e1 Enable Lint/ShadowingOuterLocalVariable for Rubocop. 2018-09-04 10:16:42 +08:00
Neil Lalonde 916164c929 REFACTOR: move remap out of script into a class 2018-08-15 12:37:52 -04:00
OsamaSayeghandSam e533f0d50f FIX: remap shouldn't fail silently when an error occurs 2018-06-19 14:49:43 +10:00
Gerhard Schlager 4af9e4ac2e Remove unused option from discourse script 2017-11-23 15:22:00 +01:00
Vinoth Kanan 25ab9e25b3 FEATURE: Option to export multiple categories using export_category method 2017-11-11 19:11:16 +05:30
Vinoth Kannan 1cd2cebe1c FEATURE: Rake task to export and import category structure 2017-11-01 17:17:05 +05:30
Jay Pfaffman df6914c681 UX: discourse restore -- sort by date 2017-10-05 15:20:14 -07:00
Jay Pfaffman b9883e7991 Tweak error messages for restore 2017-10-03 14:09:32 -07:00
Jay PfaffmanandSam 2debc12eb2 Suggest running discourse not script/discourse (#5089)
Having `discourse restore` offer copy/paste of backups is awesome, but doesn't work (rails won't load) if you call script/discourse.
2017-08-28 12:59:56 -04:00
Guo Xiang TanandGitHub 5269b652cd Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
Ryan Mulligan ad62fc57d0 regex remapping: update usage and add help description.
Here is a shell session showing what the new documenation looks like:

vagrant@discourse:~/vagrant$ bundle exec ruby ./script/discourse remap
ERROR: "discourse remap" was called with no arguments
Usage: "discourse remap [--global,--regex] FROM TO"

vagrant@discourse:~/vagrant$ bundle exec ruby ./script/discourse help remap
Usage:
  discourse remap [--global,--regex] FROM TO

Options:
      [--global], [--no-global]
      [--regex], [--no-regex]
  v, [--verbose=VERBOSE]

Description:
  Replace a string sequence FROM with TO across all tables.

  With --global option, the remapping is run on ***ALL*** databases. Instead of just running on the current database, run on every database on this machine. This option is useful for multi-site setups.

  With --regex option, use PostgreSQL function regexp_replace to do the remapping. Enabling this interprets FROM as a PostgreSQL regular expression. TO can contain references to captures in the FROM match. See the "Regular Expression
  Details" section and "regexp_replace" documentation in the PostgreSQL manual for more details.

  Examples:

  discourse remap talk.foo.com talk.bar.com # renaming a Discourse domain name

  discourse remap --regex "[/?color(=[^]]*)*]" "" # removing "color" bbcodes
2017-01-30 14:27:45 -08:00
Ryan Mulligan c62fbd9921 Revert "Revert "FEATURE: make discourse remap optionally do regex_replace (#4367)""
This reverts commit 09c117b440.
2017-01-19 09:33:49 -08:00
Robin Ward 09c117b440 Revert "FEATURE: make discourse remap optionally do regex_replace (#4367)"
This reverts commit 3fdd9596db, reversing
changes made to 222cabc741.
2016-08-08 17:05:22 -04:00
Robin WardandGitHub 3fdd9596db FEATURE: make discourse remap optionally do regex_replace (#4367)
This adds a --regex option to discourse remap to use the regexp_replace
feature in PostgreSQL. Example usage:

discourse remap --regex "\[\/?color(=[^\]]*)*]" ""

removes all the "color" bbcodes.

Also, this commit fixes the --global option, which did not work because
of how Thor processes the options.
2016-08-08 14:30:02 -04:00
Guo Xiang Tan 1d9fb8937f FIX: Backup script with custom filename needs to include version number. 2016-08-08 09:33:50 +08:00
SamandGitHub a7f09dbdd8 Revert "FEATURE: make discourse remap optionally do regex_replace" 2016-08-02 08:38:15 +10:00
Ryan MulliganandRégis Hanol 8ab2a552b9 FEATURE: make discourse remap optionally do regex_replace (#4116)
This adds a --regex option to discourse remap to use the regexp_replace
feature in PostgreSQL. Example usage:

discourse remap --regex "\[\/?color(=[^\]]*)*]" ""

removes all the "color" bbcodes.

Also, this commit fixes the --global option, which did not work because
of how Thor processes the options.
2016-07-22 10:08:41 +02:00
Robin Ward 63d0020b8e Provide hints about which files can be restored 2016-07-12 12:31:01 -04:00
Ryan Mulligan 32e9360e5a FEATURE: make discourse remap optionally do regex_replace
This adds a --regex option to discourse remap to use the regexp_replace
feature in PostgreSQL. Example usage:

discourse remap --regex "\[\/?color(=[^\]]*)*]" ""

removes all the "color" bbcodes.

Also, this commit fixes the --global option, which did not work because
of how Thor processes the options.
2016-03-24 11:44:14 -07:00
Erik Bernhardson 73c02cb2b2 Take filename to write to as optional parameter to export_category
My discourse instance will be making regular automated public backups
of specific categories. It's preferred to be able to directly control
the path and filename of the output, rather than letting discourse
choose for me. This was already mostly supported, a filename parameter
just needed to be passed through the cli app.
2016-02-12 22:02:29 -08:00
Neil Lalonde bc0b399b6a FEATURE: export/import topics and categories from one Discourse site to another. (Early-access alpha greenlight. More to do...) 2016-01-26 19:57:54 -05:00
Régis Hanol 9db3573ebb FIX: don't break the message bus when restoring a backup 2015-08-27 20:02:13 +02:00
Sam 0750b8b1ca Add multisite support to remap task 2015-07-23 14:39:55 +10:00
Régis Hanol c5d85bfad8 FEATURE: move migrate_to_new_scheme into a background job
- new hidden site setting 'migrate_to_new_scheme' (defaults to false)
- new rake tasks to toggle migration to new scheme
- FIX: migrate_to_new_scheme also works with CDN
- PERF: improve perf of the DbHelper.remap method
- REFACTOR: UrlHelper is now a class
2015-06-12 12:07:57 +02:00
Régis Hanol ca545f3fbd rename export/import in favor of backup/restore for better consistency 2014-10-10 20:04:07 +02:00
Robin Ward 17e6e0d056 FIX: Don't break out of remap action if there is a DB error. Display it
and continue.
2014-09-08 14:21:46 -04:00