Skip to content

This script was created to automate daily backups of Yandex.Disk. The script is designed to run on a Raspberry Pi Zero with Raspbian OS, but it can also work on Ubuntu or Debian OS.

License

Notifications You must be signed in to change notification settings

permyakovaa/yandex_disk_backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yandex.Disk backup tool

This script was created to automate daily backups of Yandex.Disk. The script is designed to run on a Raspberry Pi Zero with Raspbian OS, but it can also work on Ubuntu or Debian OS. Scenario of backup:

  1. Mount Yandex.Disk via webdav protocol and sync files automatically.
  2. Make a copy of a mounted disk using rsync tool.
  3. Use git for storing diffs of documents.
  4. Collect list of changes using git.
  5. Make git commit of changes.
  6. Send notification message with changes list.

To start, you need to configure a connection to Yandex.Disk using the webdav protocol.

Here's a guide on how to configure a connection:

  1. Open the Terminal on your Raspberry Pi running Raspbian.

  2. Install the necessary packages by entering the following command:

sudo apt-get install davfs2
  1. Once the installation is complete, create a directory where you want to mount the Yandex.Disk by entering the following command:
mkdir ~/yandex-disk
  1. Edit the davfs2 configuration file by entering the following command:
sudo nano /etc/davfs2/secrets
  1. Add the Yandex.Disk credentials in the following format:
https://webdav.yandex.ru username password

Replace username with your Yandex username and password with your Yandex password. Create Yandex.Disk special password for external app in Yandex account admin.

  1. Save and exit the file by pressing Ctrl + X, then Y, and finally Enter.

  2. Now, edit the davfs2 configuration file by entering the following command:

sudo nano /etc/davfs2/davfs2.conf

Uncomment the use_locks line by removing the # at the beginning of the line. Save and exit the file.

  1. To allow non-root users to mount the Yandex.Disk directory, add your user to the davfs2 group by entering the following command:
sudo usermod -aG davfs2 your_username

Replace your_username with your actual username.

  1. Next, set the proper permissions for the davfs2 configuration file by entering the following command:
sudo chmod 640 /etc/davfs2/secrets
  1. Finally, mount the Yandex.Disk directory by entering the following command:
sudo mount -t davfs https://webdav.yandex.ru ~/yandex-disk

You should now be able to access and use your Yandex.Disk files and folders through the ~/yandex-disk directory.

Remember to replace username and password in step 5 with your actual Yandex.Disk credentials.

Next step you need to setup new directory and script parameters:

  1. Making a new directory for storing a copy of your files:
mkdir ~/yadisk
mkdir ~/yadisk/files
  1. Clonew this repo inside root of your new directory:
cd ~/yadisk
git clone [email protected]:permyakovaa/yandex_disk_backup.git
  1. Make variables.sh file:
cp variables.sh.dist variables.sh
  1. Specify your unique paramaeters:
nano variables.sh
YANDEX_DISK_SOURCE_DIR=your_yandex_disk_source_dir
RSYNC_DESTINATION_DIR=your_andex_disk_destination_dir
TELEGRAM_BOT_SECRET=your_telegram_bot_secret
TELEGRAM_CHAT_ID=your_telegram_chat_id

Make a crontab job to run rsync.sh script

  1. Open crontab
crontab -e
  1. Add a new job for cron that will run every morning at 9 AM:
00 9 * * * $RSYNC_DIRECTORY_DIR/rsync.sh 2>&1 | /usr/bin/logger -t rsync.sh

About

This script was created to automate daily backups of Yandex.Disk. The script is designed to run on a Raspberry Pi Zero with Raspbian OS, but it can also work on Ubuntu or Debian OS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages