Showing posts with label backup. Show all posts
Showing posts with label backup. Show all posts

Wednesday, March 29, 2017

How to use Azure File Storage as a backup disk on Windows Server

Azure File Storage (AFS) is a file storage service hosting on Azure cloud, it can be used for backup data, files or accessing files like S3 of Amazon.

In this article, I'll show you how to create a storage, map it as a local disk on Windows Server and backup files in a schedule.

1. Create a storage

Login to your Azure portal >> click Storage accounts menu >> click plus +Add button


Below is an example for a standard storage with lowest cost. You can see Azure Storage Pricing for more details.

Once done, open the storage and copy Access keys (can copy key 1 only):

2. Map the storage as local disk

Open cmd tool and run the command like below to map the storage s a local disk on Windows Server:
net use X: \\xxxStorageName.file.core.windows.net\xxxFileFolder /u:xxxStorageName xxxKey

In which:
X: is the letter of the local disk mapped
xxxStorageName: name of the storage you keyed in step 1 (see Create storage account picture)
xxxKey: access key

To disconnect this disk, use below command:
net use X: /delete

3. Create a .bat file and put into a Task Scheduler

For example, I want to copy logs file from a folder on another disk to this storage disk. So I create a .bat file naming copylogs.bat with content as below:
@echo off
copy D:\daily\*.log X:\daily
del D:\daily\*.log

After that, I create a Task Scheduler to run this .bat file on 1 AM daily:

It's simple. Hope you can save your data or files on the cloud. It's worth when your server is damaged or something like that.

Any comment is welcome!

Monday, October 22, 2012

Auto task ftp backup mysql

This guide helps you backup mysql db via FTP with a schedule.
1. Requirements
-WinRAR
-FTP client (command lines)

2. Create batch file (for example mysql_backup.bat) with following code

@echo off
setlocal
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b)
"<your mysql folder>\bin\mysqldump.exe" -u <mysqluser> --password=<mysqlpassword> yourdb > "<your mysql backup folder>\yourdb%mydate%.sql"
"<your WinRAR folder>\WinRAR.exe" a -r -inul<your mysql backup folder>\yourdb%mydate%.rar <your mysql backup folder>\yourdb%mydate%.sql
del <your mysql backup folder>\yourdb%mydate%.sql
copy <your mysql backup folder>\yourdb%mydate%.rar <your folder to upload>
ftp -v -i -s:ftpscript.txt
del <your folder to upload>\tmcrm%mydate%.rar


3. Create ftp script file (ftpscript.txt)

open <your server>
<username>
<password>
lcd  <your folder to upload>
cd <your server folder to hold backup>
binary
mput "*.*"
disconnect
bye

4. Create Windows' task schedule for this mysql_backup.bat

End ./.
Subscribe to RSS Feed Follow me on Twitter!