AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nVault backup (https://forums.alliedmods.net/showthread.php?t=312837)

soumyadip77 12-17-2018 11:20

nVault backup
 
I want to take back up my nvault file every 30days after and it will make a new file and store new data how can i done this. using nvault array for storing

klippy 12-17-2018 12:25

Re: nVault backup
 
Make sure the vault is closed, copy the file, give it a new name (suffix a date for example) and delete the old one.

CrazY. 12-17-2018 12:34

Re: nVault backup
 
With amxx, the only ways I can suggest is: calculate in seconds how much time left to 1st day of next month and set a task with the result of the calc as its time or compare the date in plugin_init. In task function duplicate the vault file. Or consider using mysql which would be the best and easiest way to backup.

You can also try (if you have access to linux vds) to schedule backup tasks.

Bugsy 12-17-2018 19:24

Re: nVault backup
 
I'm surprised there is no file copy native, at least I couldn't find it. If you use nvault correctly you should have no need to do backups. I have not had one become corrupt on me in years, and it only happened because I was using it incorrectly (not closing the vault, server crash, etc). I can write a file copy function for you.

soumyadip77 12-17-2018 20:53

Re: nVault backup
 
Thanks Bugsy got you properly :D

SomewhereLost 12-18-2018 17:19

Re: nVault backup
 
Quote:

I can write a file copy function for you.
I'd like to have this one too.

Bugsy 12-18-2018 22:07

Re: nVault backup
 
PHP Code:

public bool:copy_file( const szSourceFile[] , const szDestFile[] )
{
    new 
iSource iDest iBytesRead bytBuffer1024 ];
    
    if ( ( 
iSource fopenszSourceFile "rb" ) ) && ( iDest fopenszDestFile "wb" ) ) )
    {
        while ( ( 
iBytesRead fread_blocksiSource bytBuffer sizeofbytBuffer ) , BLOCK_BYTE ) ) )
        {
            
fwrite_blocksiDest bytBuffer iBytesRead BLOCK_BYTE );
        }
        
        
fcloseiSource );
        
fcloseiDest );
    }
    
    return 
bool:( iSource && iDest );



soumyadip77 12-18-2018 22:08

Re: nVault backup
 
cant got :/ how i will use this

Bugsy 12-18-2018 22:24

Re: nVault backup
 
really ?

copy_file( "file you want to copy.txt" , "copied file name.txt" )

copy_file( "SomeSong.mp3" , "Copy of SomeSong.mp3" )

soumyadip77 12-18-2018 22:34

Re: nVault backup
 
got it now :D


All times are GMT -4. The time now is 07:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.