From d1f684a4f3e4c05998ed83d3e4d07ae88703d581 Mon Sep 17 00:00:00 2001 From: Costa <47926492N@ICO.SCS.local> Date: Fri, 29 Oct 2021 15:01:45 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adida=20funci=C3=B3n=20para=20crear=20un?= =?UTF-8?q?a=20copia=20de=20seguridad=20de=20la=20base=20de=20datos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docs/sqlFunctions-doc.Rmd | 42 ++++++++++++++ Docs/sqlFunctions-doc.html | 116 ++++++++++++++++++++++++++++--------- sqlFunctions.R | 11 ++++ workflow.R | 5 +- 4 files changed, 145 insertions(+), 29 deletions(-) diff --git a/Docs/sqlFunctions-doc.Rmd b/Docs/sqlFunctions-doc.Rmd index fe3eb3f..0929061 100644 --- a/Docs/sqlFunctions-doc.Rmd +++ b/Docs/sqlFunctions-doc.Rmd @@ -87,6 +87,48 @@ sqlInitialize<-function(){ --- +## sqlBackUp + +### Description +Creates a Back Up copy of the database. + +### Usage +sqlBackUp(dbfile=file,bu.dir="BU_OVARIO") + +### Arguments +Argument|Description +---|--- +dbfile| Database File location. +bu.dir| Directory under the DB file where the back up will be placed. + +### Details +Creates a Back Up copy of the database. It adds the date in front of the back up file. + +### Value +Invisibly for success (and failures cause errors). + +### Examples +```r +sqlInitialize() +sqlBackUp() +``` + +### Function +```r +sqlBackUp<-function(dbfile=file,bu.dir="BU_OVARIO"){ + db=strsplit(dbfile, "/")[[1]]%>% tail(n=1) + bu_path<-gsub(db,bu.dir,dbfile) + if (!dir.exists(bu_path)){ + dir.create(bu_path) + print(paste0("Back Up directory ", bu_path, " created")) + } + cp_bu<-paste0(bu_path, "/", format(Sys.time(), format="%Y%m%d"),"-",db) + file.copy(dbfile, cp_bu) +} +``` + +--- + ## sqlShowSamples ### Description diff --git a/Docs/sqlFunctions-doc.html b/Docs/sqlFunctions-doc.html index 6afce93..e3eb3f8 100644 --- a/Docs/sqlFunctions-doc.html +++ b/Docs/sqlFunctions-doc.html @@ -171,6 +171,7 @@ pre code {