In an earlier post, a script for synchronizing data across different machines with the help of either a USB drive or a network was discussed. Here a different approach is presented (thanks to Resmi and Philip).
If one wants to backup only those files that were created/modified in the last 24 hrs, the following script can be used
#!/bin/bash
BACKUP_DIR=`date +%d‑%b‑%G`
mkdir ~/Desktop/$BACKUP_DIR
for file in `find $HOME -mtime 0 \! -wholename "*/.*"`
do
cp -i $file ~/Desktop/$BACKUP_DIR
done
This will copy the files that were modified in the last 24 hrs from the user's home folder and sub-folders, except the hidden ones, to a folder on the Desktop named by current date, say 29-Feb-2012.
If one wants to backup only those files that were created/modified in the last 24 hrs, the following script can be used
#!/bin/bash
BACKUP_DIR=`date +%d‑%b‑%G`
mkdir ~/Desktop/$BACKUP_DIR
for file in `find $HOME -mtime 0 \! -wholename "*/.*"`
do
cp -i $file ~/Desktop/$BACKUP_DIR
done
This will copy the files that were modified in the last 24 hrs from the user's home folder and sub-folders, except the hidden ones, to a folder on the Desktop named by current date, say 29-Feb-2012.
No comments:
Post a Comment