 Even after the republic's collapse, pirates continued to use the port of Rabat, which led to the shelling of the city by Austria in 1829 after an Austrian ship had been lost to a pirate attack.The French invasion of Morocco began in the east with General Hubert Lyautey's occupation of Oujda March 1907 and in the west with the Bombardment of Casablanca August 1907.The Treaty of Fes established the protectorate March 1912.