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 {