There are many ways to take your blog backup. Even some tools are also available in market. But here I explain two ways:
1. Write one simple java program and take many blog backup together with timestamp.
2. Use Export and Import facility of blogger
1. Write one simple java code (BlogBackup.java)
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
public class BlogBackup {
public static String repo = "E:\\Blog_BACKUP\\";
public static String ext = ".xml";
public static String url1 = "http://your_blogName _1.blogspot.com/feeds/posts/default?max-results=1000";
public static String url2 = "http://your_blogName _2.blogspot.com/feeds/posts/default?max-results=1000";
public static String url3 = "http://your_blogName _3.blogspot.com/feeds/posts/default?max-results=1000";
public static void main(String[] args) {
takeBackup();
}
public static void takeBackup(){
String folderName = createFolder();
String[] url = {url1,url2,url3};
try {
for(int i=0;iString fileName = folderName+"\\"+getFileName(url[i]);
doDownload(url[i],fileName);
System.out.println("Completed :: "+fileName);
}
} catch (IOException e) {e.printStackTrace();}
}
public static String getFileName(String url){
String fileName = url.substring(url.indexOf("//")+2,url.indexOf("."));
Format formatter = new SimpleDateFormat("MMM-dd-yyyy-HH-mm");
String now = formatter.format(new Date());
return fileName+"_"+now+ext;
}
public static String createFolder(){
Format formatter = new SimpleDateFormat("MMM-dd-yyyy");
String folderName = repo + formatter.format(new Date());
System.out.println("Folder Name :: "+folderName);
File file = new File(folderName);
if(!file.exists()){
file.mkdir();
}
return folderName;
}
public static void doDownload(String blogURL, String fileName) throws IOException {
String charset = "utf-8";
URL url = new URL(blogURL);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
InputStream inputStream = null;
inputStream = url.openStream();
StringBuffer s = new StringBuffer();
if(charset==null"".equals(charset)){
charset="utf-8"; }
String rLine = null;
BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream,charset));
PrintWriter printWriter = null;
FileOutputStream fo = new FileOutputStream(fileName);
OutputStreamWriter writer = new OutputStreamWriter(fo, "utf-8");
printWriter = new PrintWriter(writer);
while ( (rLine = bReader.readLine()) != null) {
String line = rLine;
int str_len = line.length();
if (str_len > 0) {
s.append(line);
printWriter.println(line);
printWriter.flush();
}
line = null;
}
inputStream.close();
printWriter.close();
}
}
You can change the repository folder name, I used here "E:\\Blog_BACKUP\\";
Whenever you will run this java code, it will create folder as running date and inside that folder your all blog backup will come with timestamp.
Please share your comments with me ........... :)
2. Another way
Step1 : Login to your blog (http://www.blogger.com)
Step2: Go to Setting tab
Step3: You will get Blog Tools (Upper left side)
Others-->blog tools
import blog,export blog, delete blog
1. Write one simple java program and take many blog backup together with timestamp.
2. Use Export and Import facility of blogger
1. Write one simple java code (BlogBackup.java)
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
public class BlogBackup {
public static String repo = "E:\\Blog_BACKUP\\";
public static String ext = ".xml";
public static String url1 = "http://your_blogName _1.blogspot.com/feeds/posts/default?max-results=1000";
public static String url2 = "http://your_blogName _2.blogspot.com/feeds/posts/default?max-results=1000";
public static String url3 = "http://your_blogName _3.blogspot.com/feeds/posts/default?max-results=1000";
public static void main(String[] args) {
takeBackup();
}
public static void takeBackup(){
String folderName = createFolder();
String[] url = {url1,url2,url3};
try {
for(int i=0;iString fileName = folderName+"\\"+getFileName(url[i]);
doDownload(url[i],fileName);
System.out.println("Completed :: "+fileName);
}
} catch (IOException e) {e.printStackTrace();}
}
public static String getFileName(String url){
String fileName = url.substring(url.indexOf("//")+2,url.indexOf("."));
Format formatter = new SimpleDateFormat("MMM-dd-yyyy-HH-mm");
String now = formatter.format(new Date());
return fileName+"_"+now+ext;
}
public static String createFolder(){
Format formatter = new SimpleDateFormat("MMM-dd-yyyy");
String folderName = repo + formatter.format(new Date());
System.out.println("Folder Name :: "+folderName);
File file = new File(folderName);
if(!file.exists()){
file.mkdir();
}
return folderName;
}
public static void doDownload(String blogURL, String fileName) throws IOException {
String charset = "utf-8";
URL url = new URL(blogURL);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
InputStream inputStream = null;
inputStream = url.openStream();
StringBuffer s = new StringBuffer();
if(charset==null"".equals(charset)){
charset="utf-8"; }
String rLine = null;
BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream,charset));
PrintWriter printWriter = null;
FileOutputStream fo = new FileOutputStream(fileName);
OutputStreamWriter writer = new OutputStreamWriter(fo, "utf-8");
printWriter = new PrintWriter(writer);
while ( (rLine = bReader.readLine()) != null) {
String line = rLine;
int str_len = line.length();
if (str_len > 0) {
s.append(line);
printWriter.println(line);
printWriter.flush();
}
line = null;
}
inputStream.close();
printWriter.close();
}
}
You can change the repository folder name, I used here "E:\\Blog_BACKUP\\";
Whenever you will run this java code, it will create folder as running date and inside that folder your all blog backup will come with timestamp.
Please share your comments with me ........... :)
2. Another way
Step1 : Login to your blog (http://www.blogger.com)
Step2: Go to Setting tab
Step3: You will get Blog Tools (Upper left side)
Others-->blog tools
import blog,export blog, delete blog
0 comments:
Post a Comment