Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soporte-backup-db
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jesús
soporte-backup-db
Commits
c11455af
Commit
c11455af
authored
Nov 06, 2023
by
Javier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Anyado funcion para verificar que la backups a borrar sea correcta
parent
31fcfedf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
upload_pcloud_backup.py
upload_pcloud_backup.py
+19
-3
No files found.
upload_pcloud_backup.py
View file @
c11455af
...
...
@@ -47,9 +47,12 @@ def delete_file_date():
for
item
in
folder_info
[
"metadata"
][
"contents"
]:
#Recorro los ficheros de la carpeta
file_time
=
item
[
"created"
]
if
compare_date_file
(
file_time
):
#Si la fecha del fichero es anterior a 30 dias de antiguedad
#Borar fichero
pc
.
deletefile
(
fileid
=
item
[
"fileid"
])
deletes_files
.
append
(
item
[
"name"
])
#Compruebo que el fichero que vamos a borrar pertenece a dentro de la ruta folder_path
item_path
=
item
[
'path'
]
if
comprobar_item_a_borrar
(
item_path
,
folder_path
):
#Borar fichero
pc
.
deletefile
(
fileid
=
item
[
"fileid"
])
deletes_files
.
append
(
item
[
"name"
])
if
len
(
deletes_files
)
==
0
:
print
(
"No hay ficheros para borrar en Pcloud que sean más antiguos de 30 dias."
)
...
...
@@ -73,3 +76,15 @@ def compare_date_file(file_time_create: str):
else
:
return
False
def
comprobar_item_a_borrar
(
item_path
:
str
,
folder_path
:
str
):
"""Para asegurarnos que no se borre el directorio raiz de PCloud donde se almacenan las backups, comprobamos que el fichero que se borre pertenezca
al interior de la ruta del directorio raiz(folder_path).
Params:
item_path: Path de almacenamiento del fichero de backups que vamos a borrar en Pcloud, este path me lo proporciona la busqueda de ficheros
\
en un directorio.
folder_path: Path absoluta donde debería de estar ese fichero almacenado en Pcloud.
"""
if
folder_path
in
item_path
:
return
True
else
:
return
False
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment