RobbyAJM Posted March 11, 2017 Share Posted March 11, 2017 Anyone can help me ? error in while backup database.db and copying file towards 'database_backup' folder Console output: [2017-03-11 15:47:55] WARNING: [mod]\dayz\login.lua:813: Operation failed @ 'fileCopy' [Unable to copy database.db to database_backup/11.3.2017_15.47.55_K05XBrN100.db] Here's function inside login.lua function baseCopy() local randomName = randomString(10) local time = getRealTime() local second = time.second local minute = time.minute local hour = time.hour local monthday = time.monthday local month = time.month local year = time.year fileCopy("database.db","database_backup/"..monthday.."."..month + 1 ..".".. year + 1900 .."_"..hour.."."..minute.."."..second.."_"..randomName..".db") end Thanks. Link to comment
Ayush Rathore Posted March 11, 2017 Share Posted March 11, 2017 function baseCopy() local randomName = randomString(10) local time = getRealTime() local second = time.second local minute = time.minute local hour = time.hour local monthday = time.monthday local month = time.month local year = time.year local res = getResourceName(getThisResource()) local pathtocopy = ":"..res.."/".."database_backup/"..monthday.."."..month + 1 ..".".. year + 1900 .."_"..hour.."."..minute.."."..second.."_"..randomName..".db" fileCopy("database.db",pathtocopy) end Try This Link to comment
RobbyAJM Posted March 11, 2017 Author Share Posted March 11, 2017 (edited) 22 minutes ago, Ayush Rathore said: function baseCopy() local randomName = randomString(10) local time = getRealTime() local second = time.second local minute = time.minute local hour = time.hour local monthday = time.monthday local month = time.month local year = time.year local res = getResourceName(getThisResource()) local pathtocopy = ":"..res.."/".."database_backup/"..monthday.."."..month + 1 ..".".. year + 1900 .."_"..hour.."."..minute.."."..second.."_"..randomName..".db" fileCopy("database.db",pathtocopy) end Try This Thank you Ayush, i'll test it and i'll back on a minutes. EDIT: DOESNT Solved 22 minutes ago, Ayush Rathore said: function baseCopy() local randomName = randomString(10) local time = getRealTime() local second = time.second local minute = time.minute local hour = time.hour local monthday = time.monthday local month = time.month local year = time.year local res = getResourceName(getThisResource()) local pathtocopy = ":"..res.."/".."database_backup/"..monthday.."."..month + 1 ..".".. year + 1900 .."_"..hour.."."..minute.."."..second.."_"..randomName..".db" fileCopy("database.db",pathtocopy) end Try This Doesnt work, output on the console is same within the first post Edited March 11, 2017 by RobbyAJM Link to comment
Ayush Rathore Posted March 11, 2017 Share Posted March 11, 2017 tell me the position of database you want to backup Link to comment
RobbyAJM Posted March 18, 2017 Author Share Posted March 18, 2017 On 11/3/2017 at 17:51, Ayush Rathore said: tell me the position of database you want to backup Original database in dayz/database.db I want to copy the database automatic by console to dayz/database_backup/ but its doesnt work Link to comment
NeXuS™ Posted March 18, 2017 Share Posted March 18, 2017 I think it cannot be copied because the file is in use. Link to comment
undefined Posted March 18, 2017 Share Posted March 18, 2017 1 hour ago, NeXuS™ said: I think it cannot be copied because the file is in use. Me too. You should disconnect it. if database then destroyElement(database) or mysql_close(database) end -- for after file copying database = dbConnect(...) or mysql_connect(...) Link to comment
Ayush Rathore Posted March 19, 2017 Share Posted March 19, 2017 (edited) 9 hours ago, NeXuS™ said: I think it cannot be copied because the file is in use. 7 hours ago, ZoRRoM said: Me too. You should disconnect it. if database then destroyElement(database) or mysql_close(database) end -- for after file copying database = dbConnect(...) or mysql_connect(...) well it does not matter the file is being used or not you cannot delete but u can copy, Think of it as coping a gta.exe when its running but you cannot delete it 9 hours ago, RobbyAJM said: Original database in dayz/database.db I want to copy the database automatic by console to dayz/database_backup/ but its doesnt work local bsaved = false local timer = nil function baseCopy() local randomName = "" local time = getRealTime() local second = time.second local minute = time.minute local hour = time.hour local monthday = time.monthday local month = time.month local year = time.year local res = getResourceName(getThisResource()) local pathtocopy = ":dayz/database_backup/"..monthday.."."..month + 1 ..".".. year + 1900 .."_"..hour.."."..minute.."."..second.."_"..randomName..".db" if fileCopy(":dayz/database.db",pathtocopy) then outputDebugString("database saved") end end addCommandHandler("backupmydata",basecopy) function checkforNoPlayers() if getPlayerCount() == 0 and bsaved == false then baseCopy() bsaved = true killTimer(timer) end end addEventHandler("onResourceStart",root,function(res) if res == getThisResource() then timer = setTimer(checkforNoPlayers,1000,0) outputDebugString("timer for saving created") end end) addEventHandler("onPlayerJoin",root,function() if isTimer(timer) then outputDebugString("timer for saving already exists") else bsaved = false timer = setTimer(checkforNoPlayers,1000,0) outputDebugString("timer for saving created") end end) well you should use it when all the players are disconnected as it would lead to data loss if you copy while player is playing as query could be running use this above code of mine it will automatically save you data when a player count = 0 and if you want it to be forced use /backupmydata in console Edited March 19, 2017 by Ayush Rathore Link to comment
NeXuS™ Posted March 19, 2017 Share Posted March 19, 2017 Actually, the first code already worked for me, so it'll be something else I think. Link to comment
Ayush Rathore Posted March 19, 2017 Share Posted March 19, 2017 1 minute ago, NeXuS™ said: Actually, the first code already worked for me, so it'll be something else I think. well it also worked for me wait till the post owner reply Link to comment
RobbyAJM Posted March 22, 2017 Author Share Posted March 22, 2017 Solved, its working on Debian VPS But doesnt work in Windows 7 ( tested in localhost server ) Thank you Ayush Rathore & Nexus Link to comment
Ayush Rathore Posted March 23, 2017 Share Posted March 23, 2017 (edited) 14 hours ago, RobbyAJM said: Solved, its working on Debian VPS But doesnt work in Windows 7 ( tested in localhost server ) Thank you Ayush Rathore & Nexus you are welcome Edited March 23, 2017 by Ayush Rathore Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now