Skip to content

This is my stuggles (successful) with Proxmox version 8.3.3 to connect it with Microsoft OneDrive disk (e.g., from Microsoft 365) as additional storage for backups, ISOs, templates, etc. I acknowledge that the solution presented is far from being perfect, but it works. If you have any suggestions on how to improve it, feel free to share.

Notifications You must be signed in to change notification settings

adrgumula/ProxmoxOnedriveBackup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 

Repository files navigation

Proxmox OneDrive Backup

This is my experience (mostly successful) with Proxmox version 8.3.3 in connecting it to Microsoft OneDrive (e.g., from Microsoft 365) as additional storage for backups, ISOs, templates, and more. The solution uses RCLONE package and covers the installation, configuration, connection to OneDrive, and synchronization process between Proxmox and OneDrive. I acknowledge that the solution presented is far from being perfect, but it works. If you have any suggestions for improvements, feel free to contact me.

(1) md files example)

What you need?

  • Proxmox server 8+ (should works on Proxmox 7 as well)
  • Proxmox server IP address (local) PROXMOX_IP for example 192.168.1.140
  • OneDrive (I used Office 365 personal wiht 1TB OneDrive storage)
  • Putty (PC) or any SSH client able to do the port forwarding (tunelling). I use Putty running under CrossOver 24 for MacOS

Note

Understand, with Microsoft things can get complicated..

Let's start

  1. RClone - Installing & Configuration part 1

    • open Proxmox Node's shell and enter:
      curl https://rclone.org/install.sh | bash
      
    • once done run the following:
      rclone config
      
    • select n for remote
    • provide name (for example as below) - in this example I use onedrivesync
      onedrivesync
      
    • use the followings:
      select 36 (Microsoft OneDrive)
      
      client_id - leave blank/hit enter
      
      client_secret - leave blank/hit enter
      
      client_id - type global
      
      tenant - leave blank/hit enter
      
      Edit advance config? - select No
      
      Use web browser to automatically authenticate rclone with remote? - select Yes (default)
      
  2. OneDrive autorization voa Putty & WebBrowser

    • you should get an error as below as the rclone cannot resolve localpage under http://localhost:53682/
      NOTICE: Make sure your Redirect URL is set to "http://localhost:53682/" in your custom config.
      ERROR : Failed to open browser automatically (exec: "xdg-open": executable file not found in $PATH) - please go to the following link: http://127.0.0.1:53682/auth?state=xxxxxxxxxxxxxxxxxx
      NOTICE: Log in and authorize rclone for access
      NOTICE: Waiting for code...
      
    • create a tunnel using Putty:
      • Enter Host name (or IP address): for example: 192.168.1.140 port:22 and go to Connection -> SSH -> Tunnels
      • Enter 53682 as Source Port and 127.0.0.1 as Destination then click Add
      • Click Open at the buttom of the window
      • Click Accept of Putty Security Alert Window
      • Here you should see the login window to Microsoft 365 (or whatever it's called at the moment you're reading this ;) )
      • Do login to Microsoft 365
      • Click Allow on the Allow related Microsoft websites to share the cookies and website data?
      • Accept on the popup windows Let this app access your info? (1 of 1 apps)
      • Close the Putty (tunel) & return to main Proxmox shell
  3. RClone - Installing & Configuration part 2

    • Select 1
    • Select 7
    • Select 3, Select "y" Yes - default
    • Select y Yes
    • Select q Quit config
  4. First tests

    • go to Proxmox Node's shell
    • To list the contecnt of the OneDrive's root folder type following (dont forget to add : at the end!):
      • rclone lsd onedrivesync:
        
  5. Mounting OneDrive as /mnt/OneDrive (includes missing dependences installation - fuse3)

    • It time to create a folder where you'll your OneDrive content:
      • cd /mnt
        
      • mkdir onedrive
        
      • cd onedrive
        
    • the next step requires fuse to be installed. To do so just type
      • apt-get install fuse3 libfuse2
        
    • let connect /mnt/onedrive with online OneDrvie by entering following:
      • rclone mount onedrivesync: /mnt/onedrive --vfs-cache-mode writes --daemon --poll-interval 5m
        
    • Type following to check if all was connected properly (if ok you should get folder OneDrive content displayed):
      • ls /mnt/onedrive
        
  6. Addeding OneDrive drive to Proxmox:

    • In Proxmox go to your DataCenter -> Storage and select Add -> Directory
    • Add ID, Directory path and select Content as shown below:
  7. Automoving files from the localdrive to OneDrive with 5 minutes intervals:

    • Go to Promox shell and enter:
      • nano /usr/local/bin/rclone_auto_move.sh
        
    • past there following script (you can tune WATCH_DIR & DEST_DIR or your SUB_FOLDER* folders as well as sleep 1800 if you've picked up something different). After editing press Ctrl+X (Windows) or Control+X (Mac) then Y, then Enter to save & exit. Note: Comment / Uncomment specific part of the scipt below
      • #!/bin/bash
        
        WATCH_DIR="/mnt/onedrive"                       # Change to your source folder
        DEST_DIR="opendrivesync:"                       # Change to your RClone destination
        WATCH_SUBDIR="/mnt/onedrive/proxmod-backups"    # Change to your source sub-folder
        DEST_SUBDIR="opendrivesync:proxmox-backups"     # Change to your RClone destination (subfolder)
        
        inotifywait -m -e close_write --format "%w%f" "$WATCH_SUBDIR" | while read FILE
        #inotifywait -m -e close_write --format "%w%f" "$WATCH_DIR" | while read FILE
        do
            sleep 1800                              # Wait 1800s = 30 minutes
            #rclone sync "$FILE" "$DEST_DIR" --progress --delete-after
            rclone sync "$FILE" "$DEST_SUBDIR" --progress --delete-after
        done
        
    • Install missing dependeces inotifywait
      • apt install -y inotify-tools
        
    • Make above script executable:
      • chmod +x /usr/local/bin/rclone_auto_move.sh
        
    • Run the Script as a Background Service. To ensure the script runs automatically, create a systemd service. Create a new systemd unit file:
      • nano /etc/systemd/system/rclone-auto-move.service
        
    • and past this inside (save & exit)
      • [Unit]
        Description=Auto move files to cloud via RClone
        After=network-online.target
        
        [Service]
        Type=simple
        ExecStart=/usr/local/bin/rclone_auto_move.sh
        Restart=always
        User=root
        
        [Install]
        WantedBy=multi-user.target
        
    • Reload systemd to apply change
      • systemctl daemon-reload
        
    • Enable the service to start on boot:
      • systemctl enable rclone-auto-move.service
        
    • Start the service now:
      • systemctl start rclone-auto-move.service
        
    • Check if it’s running:
      • systemctl status rclone-auto-move.service
        
    • if all went fine you should get simiar message:

About

This is my stuggles (successful) with Proxmox version 8.3.3 to connect it with Microsoft OneDrive disk (e.g., from Microsoft 365) as additional storage for backups, ISOs, templates, etc. I acknowledge that the solution presented is far from being perfect, but it works. If you have any suggestions on how to improve it, feel free to share.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published