Commit graph

154 commits

Author SHA1 Message Date
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
barredterra
30d63b165b refactor: split into multiple methods 2024-02-13 11:44:50 +01:00
barredterra
2a85c4c5d9 refactor: no inline if-statement
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2024-02-13 11:29:30 +01:00
barredterra
2e4dd1ba77 refactor: setup_backup_tables 2024-02-12 18:16:47 +01:00
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
David Arnold
3abbde3284
fix: shell escaping on external commands 2024-01-30 18:23:05 +01:00
Akhil Narang
39be50c773
fix(decrypt): wrap the yield and cleanup code in try-finally
Without this, the cleanup code won't run after if `sys.exit()` is called when we yield

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-18 17:37:23 +05:30
Akhil Narang
3ccdbfbde0
fix: drop a fallback
Had some issues earlier - seems to be resolved now

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 13:01:13 +05:30
Akhil Narang
c721fcf8c4
refactor: allow setting a db user name different from the database name
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
235be44d7a
fix: add a check for gpg existing
Encrypted backup/restores just fail without a clear error message if gpg is missing

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-15 17:52:51 +05:30
Akhil Narang
58a13cfb3e
refactor: set pipefail in shell before running piped backup/restore commands
Drop the complicated logic behind storing pid and killing process if first stage of pipe fails

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-04 18:41:37 +05:30
Akhil Narang
7f433b84af
feat: allow creating a backup with the older metadata style
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Akhil Narang
a06e402f38
refactor: use a function with context manager for backup decryption
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Akhil Narang
cb7c0e653c
fix(Backup): automatically rollback decryption when object is being deleted
This allows us to not have to call it everytime before returning

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:08:48 +05:30
Akhil Narang
3b0f6de883
perf: don't extract backup files unless required
Read from the gzipped file wherever possible

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:08:48 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
barredterra
c35476256f refactor: simplify conditional logic
Command: `sourcery review --fix --enable de-morgan .`
2023-12-05 11:14:41 +01:00
David Arnold
40a2daf84c
chore: give cli invocations of dbtools a dedicated interface 2023-11-09 12:14:41 +01:00
Akhil Narang
03c88d145e
chore: print full path to backup (#22984)
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-10-30 18:04:33 +05:30
Ankush Menat
d1111fb189
refactor: DB dump executable logic (#22799) 2023-10-18 08:54:40 +00:00
Ankush Menat
fc16af2ac9 fix: fallback to mysqldump if mariadb-dump isn't available 2023-10-11 19:30:36 +05:30
Akhil Narang
091ebdd8dc
refactor(treewide): use mariadb commands directly instead of mysql (#22620)
This has been done because the mysql command issues a deprecation warning now

mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-10-10 12:49:16 +05:30
Ankush Menat
5d31667157 fix: Correct exit code for failed compressed file backup
addresses https://github.com/frappe/press/issues/1052

Similar to https://github.com/frappe/frappe/pull/18230
2023-09-25 23:15:11 +05:30
0xsaif
87c1a9d7d7
refactor: Ensure admin receives a valid backup encryption key (#22411)
* refactor: Ensure admin receives a valid backup encryption key

- Added logic to retrieve or generate a backup encryption key if not present.

* refactor: simplify code

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2023-09-15 11:40:10 +05:30
0xsaif
aa7ee1c6b9
refactor: force ipv4 localhost (#22394)
* reafctor: force ipv4 localhost

Replacing "localhost" with "127.0.0.1" in the codebase; sometimes the name localhost force-resolves to ipv6

* revert: leave localhost usage in oauth tests

Change not required.

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-09-13 16:23:23 +05:30
barredterra
b553ed98d8 refactor: inline immediately returned variable
Inline a variable to a return in the case when the
variable being declared is immediately returned
2023-08-08 18:09:49 +02:00
David Arnold
a926e64ec9
fix: procure db config from single authority (#21578)
* fix: procure db config from single authority

ensures that configuration is uniformely procured from local.conf
instead of making use of hard to audit multilevel fallback logic

Implementation Note:
- `get_db(host, port, user, password)` was stripped of any optional
  argument and therefrom all errors where fixed.
- All occurances of `grep 'frappe.db.db_'` where changed to
  `frappe.conf.db_`

* fix: revert unnecessary breaking changes
2023-07-24 10:48:29 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Ankush Menat
290a3df68d chore!: drop backup.py direct calls + pragma nocov 2022-12-13 14:18:19 +05:30
Ankush Menat
abeed35461
fix: throw exception if backup failed (#18230) 2022-09-28 14:29:38 +05:30
Ankush Menat
bdeb032fba
refactor: use separate config key for encryption (#17720) 2022-08-03 13:52:02 +05:30
Gavin D'souza
2bef29bb46 chore: Deprecate backup script + minor refactors 2022-07-22 13:21:29 +05:30
Gavin D'souza
bcfa8c276e fix: Set default port attribute for Database classes
db.default_port wil be available as a class attribute to hold defaults
for DB types.

Usage: frappe.conf.db_port or frappe.db.default_port
Why: I couldn't run the mariadb command because the defaults aren't set
for my system. server is remote / containerized. Setting port in
equivalent mysql command fixes this.
2022-07-22 13:16:26 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
chillaranand
1d763a6659 refactor: Fix flake8 issues 2022-05-19 15:34:35 +05:30
Raffael Meyer
5d61482fb3
fix: Replace password with asterisks before logging (#16743) 2022-04-26 10:30:46 +00:00
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
barredterra
1d3ec42974 fix: send_email doesn't take arguments 2022-03-20 02:20:27 +01:00
barredterra
4b8efc5ebd fix: typo in parameter name 2022-03-20 02:19:41 +01:00
barredterra
0d8733c462 refactor: remove unused import 2022-03-20 02:19:07 +01:00
mergify[bot]
5f1eadeb7a
fix(BackupGenerator): set missing attribute for class object (backport #16273) (#16301)
This is a semi-automatic backport of pull request #16273 done by [Mergify](https://mergify.com).
2022-03-16 08:10:05 +00:00
Sagar Vora
0f95c2716d fix: incorrect function name in call 2022-02-17 10:50:31 +05:30
Sagar Vora
de22bd6297 fix: improved validation 2022-02-17 10:35:15 +05:30
Anurag0911
8b7629c064
feat: Encrypted Backups (#14513)
* feat: backup-encryption

* fix: Using encryption key and Minor changes.

* fix: Sider.

* fix: Closing curly brace does not appear on the same line as the subsequent block.

* fix: Review Suggestions.

* fix: Minor changes.

* chore: Icon

* fix: Icon and Privileges Changes.
2021-11-09 13:58:57 +05:30
Gavin D'souza
3734b63c17 fix: Do partial backups instead of full in trim-database 2021-09-15 16:08:55 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Gavin D'souza
43cde90109 fix(backups): Allow individual backups of all tables
Due to previous logic, only tables under DocType table were allowed to
take partial backups. This change allows backup to be taken for
deprecated doctypes too.
2021-07-30 12:28:27 +05:30
Ankush Menat
4754ab71d1
perf(minor): remove unnecessary comprehensions
- remove several unnecessary comprehensions from functions that accept a generator.
- Using `[x for x in iter]` causes a list to be built first then passed to the outer function.
- `any` and `all` can take generator instead. This makes memory usage O(1) and actually makes these functions short-circuiting. E.g. if the first condition fails then `all` will immediately return false instead of evaluating all the entries.
- `sum`, `min`, `max` => memory usage become O(1)
- `list`, `set`, `.join()` => roughly halves memory usage, as list is not required to be built.
- lastly, it's two fewer characters to read/think about.
2021-05-12 20:38:18 +05:30
Sagar Vora
ab3be339fd fix: remove unsused variables 2021-04-22 12:56:21 +05:30