Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
-
install tools:
sudo apt-get install pigz lftp curlftpfs -
configure ftp client:
lftp (lftp :~>) set ftp:ssl-force true (lftp :~>) set ssl:verify-certificate no (lftp :~>) connect <address> (lftp <address>:~>) login <usrname> (enter password) -
create a file called
.netrcin the home directory to store credentials with the following content:machine <address> login <usrname> password <pwd>Set the permissions on the file so that you are the only user who can read it:
chmod 0600 ~/.netrc -
create mounting point for ftp server:
sudo mkdir /mnt/ftp sudo curlftpfs -o allow_other,ssl,no_verify_peer <address> /mnt/ftp -
create compressed archives using pigz of desired directories/files in some tmp folder:
hme="/home/usrname" tmp=$hme/temp/backup fconf="list all configuration files" cd $tmp tar --exclude=".git*" --exclude="*.Rproj*" --exclude=".Rhistory" --exclude=$tmp -c --use-compress-program=pigz -f $tmp/backup_home.tar.gz $hme/* tar -c --use-compress-program=pigz -f $tmp/backup_public.tar.gz $PUB_PATH/* tar -czf $tmp/backup_conf.tar.gz $fconf -
Move files to ftp folder:
mv $tmp/* /mnt/ftp -
create sh file using 5 and 6 above, then changing permissions:
chmod +x /home/usrname/cronjob/backup.sh -
add entry to crontab (in this way, the script runs at 4AM every Sunday):
0 4 * * 7 /home/usrname/cronjob/backup.sh
Add Comment
Please, Sign In to add comment