Showing posts with label copy a file from Linux to Windows. Show all posts
Showing posts with label copy a file from Linux to Windows. Show all posts

Wednesday, March 7, 2012

Schedule a task on Windows

If you are looking to Schedule a task on Windows or automate a task on Windows then you have indeed come to the right place. Read on...
We tried this on Windows XP with SP2:

Click on Start button
Click on All Programs
Click on Accessories
Click on System Tools
Click on Scheduled Tasks
Click on File
Click on New
Click on Scheduled Task
Name it what you want to.
Double click on it.
Click on Browse and select the program yo would like to run; in our case it was the batch file that we created here to copy a file from Linux to Windows.
Click on the Schedule tab and schedule task as per your needs.
I used Daily. Set the start time as per your requirement.
This will automatically carry out the task for you at the predefined time. This way I am able to automatically get the file copied from Ubuntu 9.04 to Windows. Only make sure the WIN XP is on at the predefined time.
If you might be interested in learning how to copy a file from Windows to Linux, read about it here.


I found this solution in a bid to Backup SquirrelMail on Ubuntu 9.04. If you want to learn how to automate a task on Linux, check it out here.

Automating SquirrelMail Backup on Ubuntu 9.04

If you are looking to automate SquirrelMail Backup on Ubuntu 9.04 or on any other flavor of Linux for that matter, read on...

Create a file called bak with the following contents and chmod 744 bak to make it executable.
rm  /backup/*.zip
rm -rf /backup/user_name
/usr/local/imap_tools/imapdump.pl  -f /backup/user_name -S localhost/user_name@your_domain/user_password
zip -r /backup/user_name_`date '+%d%m%Y'` /backup/user_name/.


The first line will delete any zipped files existing in the backup folder called backup in this case.

The second line will delete the backup of the IMAP folders that already exist from last time's backup. This is important since if the user had 20 emails in the last backup and he has thereafter deleted 5 emails that he does not require, the numbers get moved up and he will have 15 emails backed up numbering from 1 to 15 which will overwrite the emails numbered 1 to 15 from the previous backup. But the numbers 16 to 20 will still exist giving the user emails that he did not want and had deleted in case you want to restore SquirrelMail backup. Hence the deletion of the entire tree structure. The command rm -rf foldername removes the entire directory tree with all its files and subfolders and files.It is the Linux equivalent of deltree on DOS.

The third line backs up the IMAP folders of user user_name with password user_password on domain your_domain, storing it in folder /backup/user_name.

The fourth line zips the folder contents with subfolders and files creating a file with the username followed by date in DDMMYY format.

Learn how to copy a file from Linux to Windows here.

How to copy a file from Linux to Windows

If you are looking to copy a file from Linux to Windows, look no further.
Download pscp.exe from here. The one I downloaded earlier gave me the error : pscp.exe is not a valid win32 application. Hence, I downloaded it from here.
On your Windows PC, create a folder. I created d:\bak on my WIN XP PC and copied the pscp.exe there. I also ran a batch file called bak.bat which contains:
pscp.exe -pw users_password user@server_ip_addr:/backup/*.zip d:\bak

This will copy all the zip files from the backup folder on your Linux machine to the bak folder in the D drive of your Windows PC. This was tested on a PC running WIN XP.

If you would like to learn how to copy a file from Windows to Linux, click here.

How to Backup SquirrelMail on Ubuntu 9.04

If you have been looking for ways to backup SquirrelMail then this is the place for you.
To start with, I found that the emails are stored one in each file in /var/vmail/our-domain-name/user/cur when read and in /var/vmail/our-domain-name/user/new when unread. I tried to make a test user using ISPConfig and copied the mail folder /var/vmail/our-domain-name/user to /var/vmail/our-domain-name/testuser but I did not get the results that I was looking for. After searching the Net and learning a few things, I have come up with this how-to for other Linux enthusiasts so that they can easily backup SquirrelMail.

After logging in as sudo su:
1. Create a folder called imap_tools under /usr/local.

2. Download these files to this folder : 
    imapdump.pl : This is to backup the squirrel mail folders or IMAP folders 
   dumptoIMAP.pl : This is to put the backed up folders back into SquirrelMail if ever the need arises due to a server crash or some such.  

3. Create a folder called backup under root (/). You can create one with a different name or in some other location if you wish. 

4. /usr/local/imap_tools/imapdump.pl -f /backup/user -S localhost/user@yourdomain/users-passwd
This command will backup SquirrelMail folders belonging to user to the /backup/user folder. You will have one folder for each mailbox and the emails will be stored therein, one file per e-mail.

5. zip -r /backup/user_`date '+%d%m%Y'` /backup/user/
This command will create a file called user_07032012 (if today's date is 07/03/2012) in the /backup folder by zipping the folders and files under /backup/user. This is your answer if you did not know how to zip a folder with its subfolders in Linux or how to zip folder recursively on Linux.

6.  Next download pscp.exe from here. The one I downloaded earlier gave me the error : pscp.exe is not a valid win32 application. Hence, I downloaded it from here.

7. On your Windows PC, create a folder. I created d:\sqbak on my WIN XP PC and copied the pscp.exe here. I also created and ran a batch file called sqbak.bat which contains:
pscp.exe -pw users_password user@server_ip_addr:/backup/*.zip d:\sqbak 
This is your answer to copy a file from Linux to Windows.
To schedule this task to automatically copy a file from Linux to Windows, you can make use of the Scheduler available in Windows. For more information, click here.

8. The zipped file will now be backed up from your Linux server onto your Windows PC in d:\sqbak.

9. To check whether your SquirrelMail backup is authentic or to restore SquirrelMail backup in case of a server crash or when you upgrade to a new server or a later version of Linux.