Commit graph

163 commits

Author SHA1 Message Date
Akhil Narang
6ca4d4d167
refactor(treewide): ruff format
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-09-26 13:16:43 +05:30
Akhil Narang
8106e72981
refactor: use a database file directly, instead of an SQL file
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-04-15 13:59:16 +05:30
Akhil Narang
ad32216040
fix: support sqlite
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-04-15 13:59:16 +05:30
David Arnold
91a737d8fe
chore(typing): fix some (exotic) type errors treewide (#28210) 2024-10-21 10:02:04 +00:00
Akhil Narang
803b45b9fa
feat: ignore tar: file changed as we read it during backups
This seems to occur when new files are being created as we're archiving
the files on a site. Doesn't make sense to fail the entire backup
because of that.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-05-17 11:39:41 +05:30
Akhil Narang
ad55f5909c
fix(backup): delete failed backup even if something fails during the backup process
Not just rollback _after_ a step

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-04-24 16:23:38 +05:30
Akhil Narang
ea1c8910e6
feat: delete failed backups
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-04-10 12:57:16 +05:30
Akhil Narang
5da663d5c2
chore: cleanup get_recent_backup()
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-04-10 12:57:16 +05:30
David
39d4318a27
feat: enable db socket connection 2024-03-29 10:29:50 +01:00
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