Online backup script - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Discussion (https://forum.cuberite.org/forum-5.html) +--- Thread: Online backup script (/thread-1665.html) Pages:
1
2
|
Online backup script - xoft - 11-28-2014 I'd like to ask local Linux gurus for help. I have a linux system runing an MCServer instance (Gallery, on a RasPi). I'd like to have a script that: - runs every N hours (N ~~ 24) - packs folders "gal" and "world" and files "Gallery.cfg" and "Gallery.sqlite" into a 7z file - names the resulting 7z file based on local date (and possibly time), format yyyy-mm-dd hh-mm-ss.7z - uploads the resulting 7z file to a remote host running Linux via scp; scp needs to use a specified username and a private key in a specified file. The destination folder on the remote host should be based on the year and month of the upload (some/remote/path/yyyy-mm/yyyy-mm-dd hh-mm-ss.7z). The folder may need to be created if it doesn't exist. - uploads the resulting 7z file to a remote SMB public-writable share, again in a folder named with year and month. I have no idea how to write such a script, where to put it and how to register it so that it's run every day. Can you help me out? Thanks. RE: Online backup script - nouseforname - 11-28-2014 (11-28-2014, 08:06 AM)xoft Wrote: - runs every N hours (N ~~ 24) Does it need to be "7z"? This is not installed at linux systems by default. Usually it would be "tar" or better "tgz" which also can be used in Windows if you have the prg for 7z installed Using scp is simple, and the keyfile just need to be inside the ".ssh" folder of the user which runs the script. I can do that script for you, and also will try to explain the commands you need to execute for registration etc. Just right now i have no time Edit: - is the smb share already mounted or not? If yes hopefully using mount cifs or smbclient?! RE: Online backup script - xoft - 11-28-2014 I'd very much prefer 7z to save on diskspace, tgz archives are almost twice in size. I don't mind installing a 7zip compressor on the system. I don't have the smb share mounted, but if you tell me how to, I can do it (supposing it's a one-time action). Neither the RasPi nor the remote windows systems are ever restarted, so it should keep the share available for all time, I guess. RE: Online backup script - xoft - 11-28-2014 Thanks to @nouseforname I now have an (almost) working share accessible from the raspi. Here's the instructions: Quote:Try to install cifs at your raspberry:So far only the last part fails, the mounted share is writable only by root. RE: Online backup script - nouseforname - 11-29-2014 (11-28-2014, 10:59 PM)xoft Wrote: sudo mkdir /mnt/backupDid you use a user from the windows machine was there a promt for password? Quote:ls /mnt/backupCould you see some files from windows machine? Quote:touch /mnt/backup/mytest.txt This will be solved by using the right user for the smb mount or running the backup script as root. I think the smb mount should be done on reboot, so i will try to explain how to do that later. Now next part, the scp connect. Try to use this script at the raspberry. It will connect and create a new folder and copy one file inside. Make sure the destination path is in the home folder of the user you are using #!/bin/bash user="USER" host="example.com" port=22 dest="/path/of/create/newfolder" src="1234.567" touch 1234.567 ssh -p $port $user@$host "mkdir -p $dest" && scp -rp -P $port $src $user@$host:$dest exit let me know if this works for you. actually, do you have some experience with linux? RE: Online backup script - nouseforname - 11-29-2014 Here we go: its mostly tested in steps, but of course not complete. i think it should work like expected. just take care the instructions. https://github.com/nouseforname/MCbackup Let me know it it works or not. I will also post it at my site later Edit: just recognized, i forgot to implement 7z ( i hate 7z... its too much windows^^) anyway i will try to add it Edit 2: Added updated script with 7z or tar function to choose RE: Online backup script - xoft - 11-30-2014 When I run the script, 7z complains about missing file, it seems it doesn't like the apostrophes in the names: Code: WARNINGS for files: RE: Online backup script - nouseforname - 11-30-2014 (11-30-2014, 05:17 AM)xoft Wrote: Are the backslashes in front of the apostrophes in your script (line 69) supposed to be there, or is the forum playing tricks with the code? No this is an escape from forum, sry didnt see that. Here is github https://github.com/nouseforname/MCbackup Or from my site: http://nouseforname.de/ RE: Online backup script - xoft - 11-30-2014 I think I've ironed out the last wrinkles in the script. I'll make a PR to your GitHub with the fixes I needed to make. We'll see if it works automatically on 3:30, it's supposed to provide complete backups of the Gallery server on http://mc-server.xoft.cz/GalleryBackup/ RE: Online backup script - xoft - 11-30-2014 Yes, it works! |